10 #include <mrpt/core/lock_helper.h>
11 #include <mrpt/opengl/stock_objects.h>
12 #include <mrpt/topography/conversions.h>
13 #include <mrpt/version.h>
20 #if defined(MVSIM_HAS_ZMQ) && defined(MVSIM_HAS_PROTOBUF)
24 using namespace mvsim;
57 C.setDiagonal(std::vector<double>{var_xy, var_xy, var_z});
61 const mrpt::optional_ref<mrpt::opengl::COpenGLScene>& viz,
62 [[maybe_unused]]
const mrpt::optional_ref<mrpt::opengl::COpenGLScene>& physical,
63 [[maybe_unused]]
bool childrenOnly)
69 #if MRPT_VERSION >= 0x270
102 const auto globalSensorPose = p +
obs_model_.sensorPose.asTPose();
108 using mrpt::obs::CObservationGPS;
112 auto outObs = CObservationGPS::Create(
obs_model_);
115 outObs->sensorLabel =
name_;
118 const mrpt::math::TPoint3D noise = {
126 const auto worldRotation =
127 mrpt::poses::CPose3D::FromYawPitchRoll(georef.world_to_enu_rotation, .0, .0);
131 if (georef.world_is_utm)
133 auto posLocal = vehPoseInWorld.translation() - georef.utmRef;
135 vehPoseInWorld.x(posLocal.x);
136 vehPoseInWorld.y(posLocal.y);
137 vehPoseInWorld.z(posLocal.z);
140 const mrpt::math::TPoint3D sensorPt =
141 (worldRotation + (vehPoseInWorld + outObs->sensorPose)).translation() + noise;
144 const thread_local
auto WGS84 = mrpt::topography::TEllipsoid::Ellipsoid_WGS84();
146 const mrpt::topography::TGeodeticCoords& georefCoord = georef.georefCoord;
149 if (georefCoord.lat.decimal_value == 0 && georefCoord.lon.decimal_value == 0)
151 thread_local
bool once =
false;
156 mrpt::system::LVL_WARN,
157 "World <georeference> parameters are not set, and they are required for "
158 "properly define GNSS sensor simulation");
163 mrpt::topography::TGeocentricCoords gcPt;
164 mrpt::topography::ENUToGeocentric(sensorPt, georefCoord, gcPt, WGS84);
166 mrpt::topography::TGeodeticCoords ptCoords;
167 mrpt::topography::geocentricToGeodetic(gcPt, ptCoords, WGS84);
170 mrpt::obs::gnss::Message_NMEA_GGA msgGGA;
171 auto&
f = msgGGA.fields;
172 f.thereis_HDOP =
true;
175 mrpt::system::TTimeParts tp;
176 mrpt::system::timestampToParts(outObs->timestamp, tp);
177 f.UTCTime.hour = tp.hour;
178 f.UTCTime.minute = tp.minute;
179 f.UTCTime.sec = tp.second;
182 f.latitude_degrees = ptCoords.lat.decimal_value;
183 f.longitude_degrees = ptCoords.lon.decimal_value;
185 f.altitude_meters = ptCoords.height;
186 f.orthometric_altitude = ptCoords.height;
187 f.corrected_orthometric_altitude = ptCoords.height;
188 f.satellitesUsed = 7;
190 outObs->setMsg(msgGGA);
212 using namespace std::string_literals;
216 #if defined(MVSIM_HAS_ZMQ) && defined(MVSIM_HAS_PROTOBUF)