15 #include <mrpt/system/os.h> 16 #include <mrpt/utils/CTicTac.h> 20 using namespace mvsim;
28 void usage(
const char* argv0);
33 int main(
int argc,
char** argv)
51 thread_params.
world = &world;
57 double t_old = tictac.Tac();
58 double REALTIME_FACTOR = 1.0;
60 size_t teleop_idx_veh = 0;
62 while (!do_exit && !mrpt::system::os::kbhit())
67 double t_new = tictac.Tac();
68 double incr_time = REALTIME_FACTOR * (t_new - t_old);
82 std::this_thread::sleep_for(std::chrono::milliseconds(10));
87 std::string txt2gui_tmp;
102 teleop_idx_veh = keyevent.
keycode -
'1';
108 txt2gui_tmp += mrpt::format(
109 "Selected vehicle: %u/%u\n",
110 static_cast<unsigned>(teleop_idx_veh + 1),
111 static_cast<unsigned>(vehs.size()));
112 if (vehs.size() > teleop_idx_veh)
115 World::TListVehicles::const_iterator it_veh = vehs.begin();
116 std::advance(it_veh, teleop_idx_veh);
120 const vec3& vel = it_veh->second->getVelocityLocal();
121 txt2gui_tmp += mrpt::format(
122 "gt. vel: lx=%7.03f, ly=%7.03f, w= %7.03fdeg/s\n",
124 RAD2DEG(vel.
vals[2]));
129 it_veh->second->getVelocityLocalOdoEstimate();
130 txt2gui_tmp += mrpt::format(
131 "odo vel: lx=%7.03f, ly=%7.03f, w= %7.03fdeg/s\n",
133 RAD2DEG(vel.
vals[2]));
140 it_veh->second->getControllerInterface();
160 catch (
const std::exception& e)
162 std::cerr <<
"ERROR: " << e.what() << std::endl;
179 gui_key_events = guiparams.
keyevent;
181 std::this_thread::sleep_for(std::chrono::milliseconds(25));
187 std::cerr <<
"Usage:\n" 189 << argv0 <<
" [WORLD_MODEL.xml]\n";
void usage(const char *argv0)
Represents data loaded from a file.
void update_GUI(TUpdateGUIParams *params=NULL)
virtual void teleop_interface(const TeleopInput &in, TeleopOutput &out)
void thread_update_GUI(TThreadParams &thread_params)
std::multimap< std::string, VehicleBase * > TListVehicles
TGUIKeyEvent keyevent
Keystrokes in the window are returned here.
double get_simul_timestep() const
Simulation fixed-time interval for numerical integration.
std::string msg_lines
Messages to show.
void load_from_XML(const std::string &xml_text, const std::string &fileNameForPath=std::string("."))
const TListVehicles & getListOfVehicles() const
World::TGUIKeyEvent gui_key_events
std::string append_gui_lines
void run_simulation(double dt)
int main(int argc, char **argv)
int keycode
0=no Key. Otherwise, ASCII code.