10 #include <mrpt/core/exceptions.h> 21 std::mutex closingMtx;
40 bool closing_ =
false;
49 using namespace mvsim;
53 const auto& unlabeledArgs =
argCmd.getValue();
54 if (unlabeledArgs.size() != 2) badArgs =
true;
60 R
"XXX(Usage: mvsim launch <WORLD_MODEL.xml> 63 -v, --verbosity Set verbosity level: DEBUG, INFO (default), WARN, ERROR 68 const auto sXMLfilename = unlabeledArgs.at(1);
75 world.setMinLoggingLevel(
76 mrpt::typemeta::TEnumType<mrpt::system::VerbosityLevel>::name2value(
88 thread_params.world = &world;
93 mrpt::system::CTicTac tictac;
94 double t_old = tictac.Tac();
95 double REALTIME_FACTOR = 1.0;
97 size_t teleop_idx_veh = 0;
104 double t_new = tictac.Tac();
105 double incr_time = REALTIME_FACTOR * (t_new - t_old);
118 std::this_thread::sleep_for(std::chrono::milliseconds(10));
123 std::string txt2gui_tmp;
124 gui_key_events_mtx.lock();
126 gui_key_events_mtx.unlock();
131 case GLFW_KEY_ESCAPE:
140 teleop_idx_veh = keyevent.
keycode -
'1';
147 "Selected vehicle: %u/%u\n",
148 static_cast<unsigned>(teleop_idx_veh + 1),
149 static_cast<unsigned>(vehs.size()));
150 if (vehs.size() > teleop_idx_veh)
153 World::VehicleList::const_iterator it_veh = vehs.begin();
154 std::advance(it_veh, teleop_idx_veh);
159 it_veh->second->getVelocityLocal();
161 "gt. vel: lx=%7.03f, ly=%7.03f, w= %7.03fdeg/s\n",
162 vel.
vx, vel.
vy, mrpt::RAD2DEG(vel.
omega));
167 it_veh->second->getVelocityLocalOdoEstimate();
169 "odo vel: lx=%7.03f, ly=%7.03f, w= %7.03fdeg/s\n",
170 vel.
vx, vel.
vy, mrpt::RAD2DEG(vel.
omega));
177 it_veh->second->getControllerInterface();
188 gui_key_events_mtx.lock();
190 gui_key_events_mtx.unlock();
192 msg2gui = txt2gui_tmp;
196 thread_params.closing(
true);
205 while (!thread_params.isClosing())
215 gui_key_events_mtx.lock();
216 gui_key_events = guiparams.
keyevent;
217 gui_key_events_mtx.unlock();
220 std::this_thread::sleep_for(std::chrono::milliseconds(25));
void commonLaunchServer()
std::mutex gui_key_events_mtx
Represents data loaded from a file.
virtual void teleop_interface(const TeleopInput &in, TeleopOutput &out)
const VehicleList & getListOfVehicles() const
TCLAP::SwitchArg argHelp("h","help","Shows more detailed help for command", cmd)
mvsim::World::TGUIKeyEvent gui_key_events
int BASE_IMPEXP fprintf(FILE *fil, const char *format,...) MRPT_NO_THROWS MRPT_printf_format_check(2
std::multimap< std::string, VehicleBase::Ptr > VehicleList
TGUIKeyEvent keyevent
Keystrokes in the window are returned here.
double get_simul_timestep() const
Simulation fixed-time interval for numerical integration.
TCLAP::ValueArg< std::string > argVerbosity("v","verbose","Verbosity level", false,"INFO","ERROR|WARN|INFO|DEBUG", cmd)
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
std::string msg_lines
Messages to show.
TCLAP::UnlabeledMultiArg< std::string > argCmd("command","Command to run. Run 'mvsim help' to list commands.", false,"", cmd)
void load_from_XML(const std::string &xml_text, const std::string &fileNameForPath=std::string("."))
bool BASE_IMPEXP kbhit() MRPT_NO_THROWS
std::string append_gui_lines
void run_simulation(double dt)
void update_GUI(TUpdateGUIParams *params=nullptr)
static void mvsim_server_thread_update_GUI(TThreadParams &thread_params)
int keycode
0=no Key. Otherwise, ASCII code.