14 #include <mrpt/core/bits_math.h> 15 #include <mrpt/core/format.h> 16 #include <mrpt/gui/CDisplayWindowGUI.h> 17 #include <mrpt/img/TColor.h> 18 #include <mrpt/math/TPoint3D.h> 19 #include <mrpt/obs/CObservation.h> 20 #include <mrpt/system/COutputLogger.h> 21 #include <mrpt/system/CTicTac.h> 22 #include <mrpt/system/CTimeLogger.h> 41 class World :
public mrpt::system::COutputLogger
61 const std::string& xml_text,
62 const std::string& fileNameForPath = std::string(
"."));
135 mrpt::opengl::COpenGLScene::Ptr& gl_scene);
179 using BlockList = std::multimap<std::string, Block::Ptr>;
213 std::string
resolvePath(
const std::string& in_path)
const;
268 {
"gravity", {
"%lf", &m_gravity}},
269 {
"simul_timestep", {
"%lf", &m_simul_timestep}},
270 {
"b2d_vel_iters", {
"%i", &m_b2d_vel_iters}},
284 unsigned int win_w = 800, win_h = 600;
285 bool start_maximized =
true;
286 int refresh_fps = 20;
288 bool show_forces =
false;
289 double force_scale = 0.01;
290 double camera_distance = 80.0;
291 double fov_deg = 60.0;
296 {
"win_w", {
"%u", &win_w}},
297 {
"win_h", {
"%u", &win_h}},
298 {
"ortho", {
"%bool", &ortho}},
299 {
"show_forces", {
"%bool", &show_forces}},
300 {
"force_scale", {
"%lf", &force_scale}},
301 {
"fov_deg", {
"%lf", &fov_deg}},
302 {
"follow_vehicle", {
"%s", &follow_vehicle}},
303 {
"start_maximized", {
"%bool", &start_maximized}},
304 {
"refresh_fps", {
"%i", &refresh_fps}},
344 nanogui::Label* lbCpuUsage =
nullptr;
346 nanogui::Button* btnReplaceObject =
nullptr;
350 nanogui::CheckBox* cb =
nullptr;
362 void prepare_top_menu();
363 void prepare_status_window();
364 void prepare_editor_window();
366 void handle_mouse_operations();
const mvsim::Client & commsClient() const
SimulableList m_simulableObjects
std::shared_ptr< Simulable > Ptr
void set_simul_timestep(double timestep)
Simulation fixed-time interval for numerical integration.
const std::unique_ptr< b2World > & getBox2DWorld() const
virtual void onNewObservation([[maybe_unused]] const VehicleBase &veh, [[maybe_unused]] const mrpt::obs::CObservation *obs)
std::recursive_mutex m_world_cs
first time the GUI window is created.
std::map< std::string, TParamEntry > TParameterDefinitions
std::multimap< std::string, Simulable::Ptr > SimulableList
WorldElementList m_world_elements
mrpt::system::CTicTac m_timer_iteration
const VehicleList & getListOfVehicles() const
std::vector< InfoPerObject > gui_cbObjects
std::string xmlPathToActualPath(const std::string &modelURI) const
std::vector< std::function< void(void)> > m_gui_user_pending_tasks
std::mutex m_gui_msg_lines_mtx
mrpt::system::CTimeLogger m_timlogger
void runVisitorOnWorldElements(const world_element_visitor_t &v)
std::multimap< std::string, VehicleBase::Ptr > VehicleList
InfoPerObject gui_selectedObject
std::string follow_vehicle
void internalUpdate3DSceneObjects(mrpt::opengl::COpenGLScene::Ptr &gl_scene)
std::unique_ptr< b2World > & getBox2DWorld()
mrpt::gui::CDisplayWindowGUI::Ptr gui_win
const SimulableList & getListOfSimulableObjects() const
std::shared_ptr< Block > Ptr
std::function< void(VehicleBase &)> vehicle_visitor_t
std::multimap< std::string, Block::Ptr > BlockList
void internal_one_timestep(double dt)
std::unique_ptr< b2World > m_box2d_world
void insertBlock(const Block::Ptr &block)
TGUIKeyEvent keyevent
Keystrokes in the window are returned here.
double get_gravity() const
const mrpt::gui::CDisplayWindowGUI::Ptr & gui_window() const
double get_simul_timestep() const
Simulation fixed-time interval for numerical integration.
void internal_GUI_thread()
A rigid body. These are created via b2World::CreateBody.
void set_gravity(double accel)
std::string m_gui_msg_lines
std::mutex m_simulationStepRunningMtx
bool is_GUI_open() const
Forces closing the GUI window, if any.
std::string resolvePath(const std::string &in_path) const
b2Body * m_b2_ground_body
std::atomic_bool m_lastKeyEventValid
TGUI_Options m_gui_options
std::string msg_lines
Messages to show.
std::vector< nanogui::Label * > lbStatuses
std::function< void(WorldElementBase &)> world_element_visitor_t
std::atomic_bool m_gui_thread_must_close
std::vector< nanogui::Widget * > btns_selectedOps
std::mutex m_lastKeyEvent_mtx
void load_from_XML(const std::string &xml_text, const std::string &fileNameForPath=std::string("."))
std::atomic_bool m_gui_thread_running
const WorldElementList & getListOfWorldElements() const
mrpt::system::CTimeLogger & getTimeLogger()
void runVisitorOnVehicles(const vehicle_visitor_t &v)
b2Body * getBox2DGroundBody()
VehicleList & getListOfVehicles()
TGUIKeyEvent m_lastKeyEvent
std::mutex m_gui_user_pending_tasks_mtx
BlockList & getListOfBlocks()
World()
Default ctor: inits an empty world.
void run_simulation(double dt)
std::list< WorldElementBase::Ptr > WorldElementList
mvsim::Client & commsClient()
void process_load_walls(const rapidxml::xml_node< char > &node)
void update_GUI(TUpdateGUIParams *params=nullptr)
double get_simul_time() const
Simulation wall-clock time.
void internal_process_pending_gui_user_tasks()
std::mutex m_gui_thread_start_mtx
const TParameterDefinitions m_other_world_params
SimulableList & getListOfSimulableObjects()
const BlockList & getListOfBlocks() const
int keycode
0=no Key. Otherwise, ASCII code.
GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble f
void enqueue_task_to_run_in_gui_thread(const std::function< void(void)> &f)
void close_GUI()
a previous call to update_GUI()