26using boost::asio::ip::udp;
49 return "SkydelNetworkStream";
59 return "Data Provider";
72 std::ostringstream strs;
77 ImGui::LabelText(
str.c_str(),
"data rate [Hz]");
79 gui::widgets::HelpMarker(
"The data rate can be adjusted in Skydel: Settings/Plug-ins/<Plug-in-name>/Plug-in UI. Make sure to enable either WiFi or a LAN connection. Enabling both can lead to loss of data, because Skydel only knows one ip address.");
91 [
this](boost::system::error_code errorRcvd, std::size_t bytesRcvd) {
92 if ((!errorRcvd) && (bytesRcvd > 0))
95 std::stringstream lineStream(std::string(
_data.begin(),
_data.end()));
97 auto obsG = std::make_shared<PosVelAtt>();
98 auto obs = std::make_shared<ImuObs>(this->
_imuPos);
101 uint64_t timeSinceStartup = 0;
106 double attRoll = 0.0;
107 double attPitch = 0.0;
117 for (
size_t i = 0; i < 13; i++)
120 if (std::getline(lineStream, cell,
','))
125 timeSinceStartup =
static_cast<uint64_t
>(std::stod(cell) * 1e6);
128 posX = std::stod(cell);
131 posY = std::stod(cell);
134 posZ = std::stod(cell);
137 attRoll = std::stod(cell);
140 attPitch = std::stod(cell);
143 attYaw = std::stod(cell);
146 accelX = std::stod(cell);
149 accelY = std::stod(cell);
152 accelZ = std::stod(cell);
155 gyroX = std::stod(cell);
158 gyroY = std::stod(cell);
161 gyroZ = std::stod(cell);
165 LOG_ERROR(
"Error in network stream: Cell index is out of bounds");
171 LOG_ERROR(
"Error in IMU stream: Reading a string from csv failed");
177 Eigen::Vector3d e_position{ posX, posY, posZ };
179 Eigen::Quaterniond e_Quat_b;
182 obsG->setPosition_e(e_position);
183 Eigen::Vector3d velDummy{ 0, 0, 0 };
184 obsG->setVelocity_e(velDummy);
185 obsG->setAttitude_e_Quat_b(e_Quat_b);
188 obs->p_acceleration = { accelX, accelY, accelZ };
189 obs->p_angularRate = { gyroX, gyroY, gyroZ };
192 InsTime currentTime = util::time::GetCurrentInsTime();
193 if (!currentTime.
empty())
195 obs->insTime = currentTime;
196 obsG->insTime = currentTime;
205 LOG_WARN(
"{}: Potentially lost a message. Previous message was at {} and current message at {} which is a time difference of {} seconds.",
nameId(),
229 std::chrono::duration<double> elapsed_seconds = std::chrono::steady_clock::now() -
_startPoint;
244 LOG_DATA(
"Elapsed Seconds = {}", elapsed_seconds.count());
250 LOG_ERROR(
"Error receiving the network stream from Skydel");
Transformation collection.
Text Help Marker (?) with Tooltip.
Parent Class for all IMU Observations.
Utility class for logging to console and file.
#define LOG_DATA
All output which occurs repeatedly every time observations are received.
#define LOG_ERROR
Error occurred, which stops part of the program to work, but not everything.
#define LOG_WARN
Error occurred, but a fallback option exists and program continues to work normally.
#define LOG_TRACE
Detailled info to trace the execution of the program. Should not be called on functions which receive...
Position, Velocity and Attitude Storage Class.
Node receiving UDP packages from the Skydel GNSS simulator Instinct plugin.
Keeps track of the current real/simulation time.
static std::string type()
Returns the type of the data class.
Imu(const Imu &)=delete
Copy constructor.
ImuPos _imuPos
Position and rotation information for conversion from platform to body frame.
The class is responsible for all time-related tasks.
constexpr bool empty() const
Checks if the Time object has a value.
ImVec2 _guiConfigDefaultWindowSize
OutputPin * CreateOutputPin(const char *name, Pin::Type pinType, const std::vector< std::string > &dataIdentifier, OutputPin::PinData data=static_cast< void * >(nullptr), int idx=-1)
Create an Output Pin object.
std::string nameId() const
Node name and id.
bool _onlyRealTime
Whether the node can run in post-processing or only real-time.
void invokeCallbacks(size_t portIndex, const std::shared_ptr< const NodeData > &data)
Calls all registered callbacks on the specified output port.
bool _hasConfig
Flag if the config window should be shown.
static std::string type()
Returns the type of the data class.
std::thread _testThread
Thread for receiver fct.
std::string type() const override
String representation of the Class Type.
void deinitialize() override
Deinitialize the node.
bool initialize() override
Initialize the node.
void guiConfig() override
ImGui config window which is shown on double click.
boost::asio::ip::udp::endpoint _senderEndpoint
Boost udp endpoint.
int _startCounter
Counter for packages that are skipped until data rate is shown.
bool resetNode() override
Resets the node. It is guaranteed that the node is initialized when this is called.
static constexpr size_t OUTPUT_PORT_INDEX_IMU_OBS
Port number of the Skydel-ImuObs output.
static constexpr size_t OUTPUT_PORT_INDEX_GNSS_OBS
Port number of the Skydel-GnssObs output.
bool _isStartup
Startup handler: used in 'initialize()' to differentiate between startup and re-initialization.
int _packageCount
Counter for received packages.
static std::string category()
String representation of the Class Category.
bool _stop
Stop handler: once true, the asynchronous receive function stops.
static std::string typeStatic()
String representation of the Class Type.
~SkydelNetworkStream() override
Destructor.
boost::asio::io_context _ioservice
Asynchronous receive fct.
std::array< char, _maxLength > _data
Network data stream array.
uint64_t _lastMessageTime
Stores the time of the last received message.
SkydelNetworkStream()
Default constructor.
boost::asio::ip::udp::socket _socket
Boost udp socket.
std::chrono::steady_clock::time_point _startPoint
Time point where the first package has been received.
double _dataRate
Data rate of the received network stream [Hz].
static constexpr unsigned int _maxLength
Network data stream buffer size (boost::asio)
void do_receive()
Receive Skydel network stream data.
Eigen::Vector3< typename Derived::Scalar > ecef2lla_WGS84(const Eigen::MatrixBase< Derived > &e_position)
Converts Earth-centered-Earth-fixed coordinates into latitude, longitude and altitude using WGS84.
Eigen::Quaternion< Scalar > e_Quat_n(const Scalar &latitude, const Scalar &longitude)
Quaternion for rotations from navigation to Earth-fixed frame.
Eigen::Quaternion< Scalar > n_Quat_b(Scalar roll, Scalar pitch, Scalar yaw)
Quaternion for rotations from body to navigation frame.