UAV Simulator
|
Specialized Easy3D viewer class for UAV simulation with GUI integration. More...
#include <simviewer.h>
Public Member Functions | |
SimViewer (const std::string &title) | |
Constructor. | |
~SimViewer () override | |
Destructor. | |
void | setAircraft (Aircraft *aircraft) |
Sets the aircraft to be displayed in the viewer. | |
void | setGNC (GNC *gnc) |
Sets the GNC object for displaying trim and linearisation results. | |
![]() | |
ViewerImGui (const std::string &title="Easy3D ViewerImGui", int samples=4, int gl_major=3, int gl_minor=2, bool full_screen=false, bool resizable=true, int depth_bits=24, int stencil_bits=8, int width=800, int height=600) | |
Constructor for ViewerImGui. | |
~ViewerImGui () override | |
Destructor. Cleans up ImGui and OpenGL resources. | |
Protected Member Functions | |
void | draw () const override |
Custom draw function called every frame. Handles rendering of the aircraft and any overlays. | |
bool | key_press_event (int key, int modifiers) override |
Key press event handler. | |
void | pre_draw () override |
Called before rendering each frame (for ImGui setup). | |
void | post_draw () override |
Called after rendering each frame (for ImGui overlays). | |
![]() | |
void | init () override |
Initializes ImGui and binds it to the OpenGL and GLFW context. | |
void | pre_draw () override |
Called before rendering the scene. | |
void | post_draw () override |
Called after rendering the scene. | |
void | post_resize (int w, int h) override |
Handles window resize events. | |
bool | callback_event_cursor_pos (double x, double y) override |
Handles mouse movement. | |
bool | callback_event_mouse_button (int button, int action, int modifiers) override |
Handles mouse button events. | |
bool | callback_event_keyboard (int key, int action, int modifiers) override |
Handles keyboard key events. | |
bool | callback_event_character (unsigned int codepoint) override |
Handles character input events. | |
bool | callback_event_scroll (double dx, double dy) override |
Handles mouse scroll events. | |
void | draw_menu_file () |
Draws the "File" menu in the main menu bar. | |
void | draw_menu_view () |
Draws the "View" menu in the main menu bar. | |
float | pixel_ratio () |
Computes the pixel ratio between framebuffer and window size. | |
float | widget_scaling () |
Calculates the widget scaling factor. | |
void | reload_font (int font_size=16) |
Reloads the ImGui font at a given font size. | |
Private Member Functions | |
void | drawAnalysisTabs () const |
Draws the Analysis tab with trim and linearisation results. | |
void | DisplayMatrix (const std::string &name, const Eigen::MatrixXd &M) const |
Utility function to display Eigen matrices in ImGui. | |
Private Attributes | |
easy3d::TextRenderer * | text_renderer_ |
Renders on-screen text such as FPS or labels. | |
Aircraft * | aircraft_ = nullptr |
Pointer to the Aircraft object for simulation. | |
GNC * | gnc_ = nullptr |
Pointer to the GNC object for analysis data (NEW) | |
bool | show_controls_ = true |
If true, display control panel in ImGui. | |
std::vector< float > | time_data_ |
std::vector< std::vector< float > > | state_data_ = std::vector<std::vector<float>>(18) |
float | plot_time_ = 0.0f |
Additional Inherited Members | |
![]() | |
float | menu_height_ |
Height of the menu bar, used for adjusting overlay positions. | |
![]() | |
static ImGuiContext * | context_ |
Global ImGui context shared across all viewer instances. | |
Specialized Easy3D viewer class for UAV simulation with GUI integration.
Inherits from ViewerImGui
to enable ImGui-based user interface. Allows for rendering an aircraft model and custom GUI panels.
SimViewer::SimViewer | ( | const std::string & | title | ) |
Constructor.
Constructor for SimViewer. Initializes the Easy3D viewer with ImGui support and sets up a text renderer.
title | Title of the simulation window. |
title | Title of the window. |
|
override |
Destructor.
Destructor for SimViewer. Cleans up text renderer memory.
|
private |
Utility function to display Eigen matrices in ImGui.
Displays an Eigen matrix in ImGui in a simple grid format.
name | Matrix label. |
M | The matrix to display. |
name | Matrix label to display above the grid. |
M | The Eigen matrix to display. |
Each entry is shown with fixed precision formatting. Columns are separated with ImGui::SameLine() for compact layout.
|
overrideprotected |
Custom draw function called every frame. Handles rendering of the aircraft and any overlays.
Main rendering function. Called every frame to render 3D geometry and aircraft HUD.
|
private |
Draws the Analysis tab with trim and linearisation results.
Draws the Analysis tab with selectable sub-tabs for trim values and system matrices.
This method uses ImGui to present an "Analysis" window with sub-tabs for:
Data is sourced from the associated GNC instance set via setGNC().
|
overrideprotected |
Key press event handler.
Handles keyboard input for controlling aircraft.
key | The GLFW key code. |
modifiers | Modifier keys (e.g., Shift, Ctrl). |
key | GLFW key code |
modifiers | Key modifiers (Shift, Ctrl, etc.) |
|
overrideprotected |
Called after rendering each frame (for ImGui overlays).
Called after the main draw function. Displays ImGui control panel for aircraft control surfaces. Displays Real-Time plots of the UAV state variables.
TODO get directly from sim
|
overrideprotected |
Called before rendering each frame (for ImGui setup).
Called before each frame is drawn. Ensures ImGui and Easy3D are synchronized.
void SimViewer::setAircraft | ( | Aircraft * | aircraft | ) |
void SimViewer::setGNC | ( | GNC * | gnc | ) |
|
private |
|
private |
If true, display control panel in ImGui.
|
private |
|
private |
Renders on-screen text such as FPS or labels.
|
private |