28using boost::asio::ip::udp;
51 return "SkydelNetworkStream";
61 return "Data Provider";
74 std::ostringstream strs;
79 ImGui::LabelText(
str.c_str(),
"data rate [Hz]");
81 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.");
93 [
this](boost::system::error_code errorRcvd, std::size_t bytesRcvd) {
94 if ((!errorRcvd) && (bytesRcvd > 0))
97 std::stringstream lineStream(std::string(
_data.begin(),
_data.end()));
99 auto obsG = std::make_shared<PosVelAtt>();
100 auto obs = std::make_shared<ImuObs>(this->
_imuPos);
103 uint64_t timeSinceStartup = 0;
108 double attRoll = 0.0;
109 double attPitch = 0.0;
119 for (
size_t i = 0; i < 13; i++)
122 if (std::getline(lineStream, cell,
','))
127 timeSinceStartup =
static_cast<uint64_t
>(std::stod(cell) * 1e6);
130 posX = std::stod(cell);
133 posY = std::stod(cell);
136 posZ = std::stod(cell);
139 attRoll = std::stod(cell);
142 attPitch = std::stod(cell);
145 attYaw = std::stod(cell);
148 accelX = std::stod(cell);
151 accelY = std::stod(cell);
154 accelZ = std::stod(cell);
157 gyroX = std::stod(cell);
160 gyroY = std::stod(cell);
163 gyroZ = std::stod(cell);
167 LOG_ERROR(
"Error in network stream: Cell index is out of bounds");
173 LOG_ERROR(
"Error in IMU stream: Reading a string from csv failed");
179 Eigen::Vector3d e_position{ posX, posY, posZ };
181 Eigen::Quaterniond e_Quat_b;
184 obsG->setPosition_e(e_position);
185 Eigen::Vector3d velDummy{ 0, 0, 0 };
186 obsG->setVelocity_e(velDummy);
187 obsG->setAttitude_e_Quat_b(e_Quat_b);
190 obs->p_acceleration = { accelX, accelY, accelZ };
191 obs->p_angularRate = { gyroX, gyroY, gyroZ };
194 InsTime currentTime = util::time::GetCurrentInsTime();
195 if (!currentTime.
empty())
197 obs->insTime = currentTime;
198 obsG->insTime = currentTime;
207 LOG_WARN(
"{}: Potentially lost a message. Previous message was at {} and current message at {} which is a time difference of {} seconds.",
nameId(),
231 std::chrono::duration<double> elapsed_seconds = std::chrono::steady_clock::now() -
_startPoint;
246 LOG_DATA(
"Elapsed Seconds = {}", elapsed_seconds.count());
252 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
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.
OutputPin * CreateOutputPin(Node *node, 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.
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.