Debian Codegraph @

apps/holonomic-navigator-demo/holonomic_navigator_demoMain.h

raw
1 /* +------------------------------------------------------------------------+
2 | Mobile Robot Programming Toolkit (MRPT) |
3 | https://www.mrpt.org/ |
4 | |
5 | Copyright (c) 2005-2026, Individual contributors, see AUTHORS file |
6 | See: https://www.mrpt.org/Authors - All rights reserved. |
7 | Released under BSD License. See: https://www.mrpt.org/License |
8 +------------------------------------------------------------------------+ */
9
10 #ifndef HOLONOMIC_NAVIGATOR_DEMOMAIN_H
11 #define HOLONOMIC_NAVIGATOR_DEMOMAIN_H
12
13 //(*Headers(holonomic_navigator_demoFrame)
14 #include <wx/frame.h>
15 #include <wx/menu.h>
16 #include <wx/notebook.h>
17 #include <wx/panel.h>
18 #include <wx/radiobox.h>
19 #include <wx/sizer.h>
20 #include <wx/stattext.h>
21 #include <wx/statusbr.h>
22 #include <wx/textctrl.h>
23 #include <wx/things/toggle.h>
24 #include <wx/timer.h>
25
26 #include "MyGLCanvas.h"
27 //*)
28
29 #include <mrpt/maps/COccupancyGridMap2D.h>
30 #include <mrpt/nav.h>
31 #include <mrpt/opengl/CDisk.h>
32 #include <mrpt/opengl/CPlanarLaserScan.h> // It's in the lib mrpt-maps
33 #include <mrpt/opengl/CPointCloud.h>
34 #include <mrpt/opengl/CSetOfLines.h>
35 #include <mrpt/opengl/CSetOfObjects.h>
36 #include <mrpt/opengl/CSimpleLine.h>
37
38 #include <memory> // unique_ptr
39
40 // JLBC: Unix X headers have these funny things...
41 #ifdef Button1
42 #undef Button1
43 #undef Button2
44 #undef Button3
45 #undef Button4
46 #undef Button5
47 #undef Button6
48 #undef Button7
49 #endif
50 // To avoid conflicts between Eigen & X11 headers
51 #ifdef Success
52 #undef Success
53 #endif
54
55 class holonomic_navigator_demoFrame : public wxFrame
56 {
57 public:
58 holonomic_navigator_demoFrame(wxWindow* parent, wxWindowID id = -1);
59 ~holonomic_navigator_demoFrame() override;
60
61 private:
62 //(*Handlers(holonomic_navigator_demoFrame)
63 void OnQuit(wxCommandEvent& event);
64 void OnAbout(wxCommandEvent& event);
65 void OnbtnPlaceRobotClick(wxCommandEvent& event);
66 void OnbtnPlaceTargetClick(wxCommandEvent& event);
67 void OnbtnStartClick(wxCommandEvent& event);
68 void OnbtnStopClick(wxCommandEvent& event);
69 void OntimRunSimulTrigger(wxTimerEvent& event);
70 void OnMenuItemChangeVisibleStuff(wxCommandEvent& event);
71 void OnMenuItemClearRobotPath(wxCommandEvent& event);
72 void OnbtnLoadMapClick(wxCommandEvent& event);
73 //*)
74
75 //(*Identifiers(holonomic_navigator_demoFrame)
76 static const long ID_BUTTON1;
77 static const long ID_BUTTON2;
78 static const long ID_BUTTON3;
79 static const long ID_BUTTON6;
80 static const long ID_BUTTON7;
81 static const long ID_BUTTON4;
82 static const long ID_BUTTON5;
83 static const long ID_RADIOBOX1;
84 static const long ID_TEXTCTRL1;
85 static const long ID_PANEL1;
86 static const long ID_PANEL2;
87 static const long ID_NOTEBOOK1;
88 static const long ID_STATICTEXT2;
89 static const long ID_STATICTEXT1;
90 static const long ID_XY_GLCANVAS;
91 static const long ID_CUSTOM1;
92 static const long ID_TEXTCTRL2;
93 static const long ID_MENUITEM4;
94 static const long idMenuQuit;
95 static const long ID_MENUITEM1;
96 static const long ID_MENUITEM2;
97 static const long ID_MENUITEM3;
98 static const long idMenuAbout;
99 static const long ID_STATUSBAR1;
100 static const long ID_TIMER1;
101 //*)
102
103 //(*Declarations(holonomic_navigator_demoFrame)
104 wxTimer timRunSimul;
105 wxTextCtrl* edInfoLocalView;
106 wxCustomButton* btnStop;
107 wxNotebook* Notebook1;
108 wxRadioBox* rbHoloMethod;
109 wxMenuItem* MenuItem5;
110 wxStaticText* StaticText2;
111 wxCustomButton* btnStart;
112 wxMenu* Menu3;
113 wxTextCtrl* edHoloParams;
114 wxCustomButton* btnLoadMap;
115 wxCustomButton* btnQuit;
116 wxPanel* Panel1;
117 wxStaticText* StaticText1;
118 wxMenuItem* MenuItem3;
119 wxMenuItem* mnuViewRobotPath;
120 wxStatusBar* StatusBar1;
121 wxCustomButton* btnHelp;
122 wxCustomButton* btnPlaceRobot;
123 wxPanel* Panel2;
124 wxMenuItem* mnuViewMaxRange;
125 wxCustomButton* btnPlaceTarget;
126 CMyGLCanvas* m_plotScan;
127 CMyGLCanvas* m_plot3D;
128 //*)
129
130 DECLARE_EVENT_TABLE()
131
132 /* Methods: */
133 void updateMap3DView();
134 void reinitSimulator(); // Create navigator object & load params from GUI
135 void simulateOneStep(double time_step);
136 void updateViewsDynamicObjects(); // Update 3D object positions and refresh
137 // views.
138
139 void Onplot3DMouseClick(wxMouseEvent& event);
140 void Onplot3DMouseMove(wxMouseEvent& event);
141
142 /* Vars: */
143 struct TOptions : public mrpt::config::CLoadableOptions
144 {
145 double ROBOT_MAX_SPEED{4.0};
146 double MAX_SENSOR_RADIUS{5.0};
147 uint64_t SENSOR_NUM_RANGES{181};
148 double SENSOR_RANGE_NOISE_STD{0.02};
149
150 TOptions() = default;
151 void loadFromConfigFile(
152 const mrpt::config::CConfigFileBase& source,
153 const std::string& section) override; // See base docs
154 void saveToConfigFile(
155 mrpt::config::CConfigFileBase& source,
156 const std::string& section) const override; // See base docs
157 };
158
159 TOptions m_simul_options;
160
161 /** The state of the cursor onto the 3D view:
162 */
163 enum TCursorPickState
164 {
165 cpsNone = 0,
166 cpsPickTarget,
167 cpsPlaceRobot
168 };
169
170 std::unique_ptr<mrpt::nav::CAbstractHolonomicReactiveMethod> m_holonomicMethod;
171 mrpt::maps::COccupancyGridMap2D m_gridMap;
172 mrpt::math::TPose2D m_targetPose;
173 mrpt::math::TPose2D m_robotPose;
174
175 mrpt::system::CTicTac m_runtime;
176 /** Of the cursor on the 3D view (in world coordinates at Z=0) */
177 mrpt::math::TPoint2D m_curCursorPos;
178 /** The state of the cursor onto the 3D view: */
179 TCursorPickState m_cursorPickState;
180
181 // ========= Opengl View: Map & robot =======
182 mrpt::opengl::CSetOfObjects::Ptr gl_grid;
183 mrpt::opengl::CSetOfObjects::Ptr gl_robot, gl_target;
184 mrpt::opengl::CSetOfObjects::Ptr m_gl_placing_nav_target;
185 mrpt::opengl::CSetOfObjects::Ptr m_gl_placing_robot;
186 mrpt::opengl::CDisk::Ptr gl_robot_sensor_range;
187 mrpt::opengl::CSetOfLines::Ptr gl_robot_path;
188 mrpt::opengl::CPlanarLaserScan::Ptr gl_scan3D, gl_scan2D;
189 mrpt::opengl::CPointCloud::Ptr gl_path;
190
191 // ========= Opengl View: Local view (holonomic) =======
192 mrpt::opengl::CSimpleLine::Ptr gl_line_direction;
193 mrpt::opengl::CPointCloud::Ptr gl_rel_target;
194 mrpt::opengl::CSetOfLines::Ptr gl_nd_gaps;
195 };
196
197 #endif // HOLONOMIC_NAVIGATOR_DEMOMAIN_H