Go to the documentation of this file.
9 #include <mrpt/core/lock_helper.h>
10 #include <mrpt/math/TTwist2D.h>
11 #include <mrpt/obs/CObservationOdometry.h>
12 #include <mrpt/poses/CPose3DQuat.h>
13 #include <mrpt/serialization/CArchive.h>
14 #include <mrpt/system/filesystem.h>
15 #include <mrpt/version.h>
20 using namespace mvsim;
31 MRPT_LOG_DEBUG(
"Dtor: Waiting for GUI thread to quit...");
34 MRPT_LOG_DEBUG(
"Dtor: GUI thread shut down successful.");
38 MRPT_LOG_DEBUG(
"Dtor: GUI thread already shut down.");
73 #if MRPT_VERSION >= 0x270
76 worldVisual_->getViewport()->lightParameters().ambient = {
86 auto glVizSensors = mrpt::opengl::CSetOfObjects::Create();
87 glVizSensors->setName(
"group_sensors_viz");
92 getTimeLogger().setMinLoggingLevel(this->getMinLoggingLevel());
114 bool is_relative =
true;
115 if (
s.size() > 2 &&
s[1] ==
':' && (
s[2] ==
'/' ||
s[2] ==
'\\')) is_relative =
false;
116 if (
s.size() > 0 && (
s[0] ==
'/' ||
s[0] ==
'\\')) is_relative =
false;
122 return mrpt::system::toAbsolutePath(ret);
128 if (veh.second) v(*veh.second);
140 if (b.second) v(*b.second);
145 #if defined(MVSIM_HAS_ZMQ) && defined(MVSIM_HAS_PROTOBUF)
147 client_.setVerbosityLevel(this->getMinLoggingLevel());
157 o.second->registerOnServer(client_);
159 lckListObjs.unlock();
169 block->setBlockIndex(
blocks_.size());
172 blocks_.insert(BlockList::value_type(block->getName(), block));
178 std::make_pair(block->getName(), std::dynamic_pointer_cast<Simulable>(block)));
197 static bool first =
true;
210 const auto nJoy =
joystick_->getJoysticksCount();
214 "[World::getJoystickState()] No Joystick found, disabling "
215 "joystick-based controllers.");
225 joystick_->getJoystickPosition(nJoy, joyState);
231 const size_t JOY_AXIS_AZIMUTH = 3;
235 auto lck = mrpt::lockHelper(
gui_.
gui_win->background_scene_mtx);
237 cam.setAzimuthDegrees(cam.getAzimuthDegrees() - js.
axes[JOY_AXIS_AZIMUTH]);
251 using namespace std::string_literals;
262 mrpt::system::fileNameChangeExtension(
save_to_rawlog_, v.first +
".rawlog"s);
264 MRPT_LOG_INFO_STREAM(
"Creating dataset file: " <<
fileName);
284 const auto optZ = obj->getElevationAt(worldXY);
285 if (optZ) ret.insert(*optZ);
291 if (
auto it = lut.find(lutCoord); it != lut.end())
293 for (
const auto& obj : it->second)
296 const auto optZ = obj->getElevationAt(worldXY);
297 if (optZ) ret.insert(*optZ);
302 if (ret.empty()) ret.insert(.0
f);
mrpt::opengl::COpenGLScene::Ptr worldVisual_
static const char * fileName
std::mutex simulableObjectsMtx_
const LUTCache & getLUTCacheOfObjects() const
Ensure the cache is built and up-to-date, then return it:
const std::string & getName() const
const B2_API b2Vec2 b2Vec2_zero
Useful constant.
void dispatchOnObservation(const Simulable &veh, const mrpt::obs::CObservation::Ptr &obs)
static lut_2d_coordinates_t xy_to_lut_coords(const mrpt::math::TPoint2Df &p)
static void FreeOpenGLResources()
std::vector< bool > buttons
float getHighestElevationUnder(const mrpt::math::TPoint3Df &queryPt) const
void internalOnObservation(const Simulable &veh, const mrpt::obs::CObservation::Ptr &obs)
std::string save_to_rawlog_
bool sensor_has_to_create_egl_context()
std::function< void(WorldElementBase &)> world_element_visitor_t
void force_set_simul_time(double newSimulatedTime)
Normally should not be called by users, for internal use only.
std::function< void(Block &)> block_visitor_t
std::vector< float > axes
SimulableList simulableObjects_
mrpt::gui::CDisplayWindowGUI::Ptr gui_win
std::recursive_mutex worldPhysicalMtx_
std::string local_to_abs_path(const std::string &in_path) const
std::string serverAddress_
std::string xmlPathToActualPath(const std::string &modelURI) const
std::vector< bool > buttons
World()
Default ctor: inits an empty world.
std::string resolve_path(const std::string &uri)
std::vector< on_observation_callback_t > callbacksOnObservation_
void runVisitorOnVehicles(const vehicle_visitor_t &v)
std::string trim(const std::string &s)
std::map< std::string, std::shared_ptr< mrpt::io::CFileGZOutputStream > > rawlog_io_per_veh_
LightOptions lightOptions_
void runVisitorOnBlocks(const block_visitor_t &v)
void insertBlock(const Block::Ptr &block)
void internal_advertiseServices()
std::unordered_map< lut_2d_coordinates_t, std::vector< Simulable::Ptr >, LutIndexHash > LUTCache
std::vector< float > axes
void free_opengl_resources()
mrpt::opengl::COpenGLScene worldPhysical_
WorldElementList worldElements_
RemoteResourcesManager remoteResources_
std::mutex rawlog_io_mtx_
std::function< void(VehicleBase &)> vehicle_visitor_t
std::optional< mvsim::TJoyStickEvent > getJoystickState() const
void internal_initialize()
std::shared_ptr< Block > Ptr
std::set< float > getElevationsAt(const mrpt::math::TPoint2D &worldXY) const
mrpt::system::CTimeLogger & getTimeLogger()
std::unique_ptr< b2World > box2d_world_
bool simulator_must_close() const
void runVisitorOnWorldElements(const world_element_visitor_t &v)
std::recursive_mutex world_cs_
std::optional< Joystick > joystick_
mvsim
Author(s):
autogenerated on Wed May 28 2025 02:13:08