51 return "Data Provider";
56 if (ImGui::InputTextWithHint(
"SensorPort",
"/dev/ttyUSB0", &
_sensorPort))
64 "- \"COM1\" (Windows format for physical and virtual (USB) serial port)\n"
65 "- \"/dev/ttyS1\" (Linux format for physical serial port)\n"
66 "- \"/dev/ttyUSB0\" (Linux format for virtual (USB) serial port)\n"
67 "- \"/dev/tty.usbserial-FTXXXXXX\" (Mac OS X format for virtual (USB) serial port)\n"
68 "- \"/dev/ttyS0\" (CYGWIN format. Usually the Windows COM port number minus 1. This would connect to COM1)");
89 if (j.contains(
"UartSensor"))
93 if (j.contains(
"Imu"))
139 _sensor->unregisterAsyncPacketReceivedHandler();
151 auto* lnSensor =
static_cast<Ln200Sensor*
>(userData);
153 if (p.type() == uart::protocol::Packet::Type::TYPE_BINARY)
155 auto obs = std::make_shared<ImuObsWDelta>(lnSensor->_imuPos);
158 auto reverseBits = [](uint16_t& word) {
159 word =
static_cast<uint16_t
>(((word & 0x5555) << 1) | ((word & 0xAAAA) >> 1));
160 word =
static_cast<uint16_t
>(((word & 0x3333) << 2) | ((word & 0xCCCC) >> 2));
161 word =
static_cast<uint16_t
>(((word & 0x0F0F) << 4) | ((word & 0xF0F0) >> 4));
162 word =
static_cast<uint16_t
>(((word & 0x00FF) << 8) | ((word & 0xFF00) >> 8));
165 const std::vector<uint8_t>& bytes = p.getRawData();
166 std::array<uint16_t, 14> rawWords{};
167 std::array<double, 12> processedWords{};
170 for (uint8_t i = 0; i < 14; ++i)
172 uint8_t index = i * 2;
173 uint16_t word =
static_cast<uint16_t
>(bytes[index + 1]) |
static_cast<uint16_t
>(
static_cast<uint16_t
>(bytes[index]) << 8);
175 rawWords.at(i) = word;
202 for (uint8_t i = 0; i < 3; ++i)
204 processedWords.at(i) =
static_cast<int16_t
>(rawWords.at(i)) * (1.0 / 16384.0);
207 for (uint8_t i = 3; i < 6; ++i)
209 processedWords.at(i) =
static_cast<int16_t
>(rawWords.at(i)) * (1.0 / 262144.0);
211 double dVelX = processedWords[0];
212 double dVelY = processedWords[1];
213 double dVelZ = processedWords[2];
214 double dAngleX = processedWords[3];
215 double dAngleY = processedWords[4];
216 double dAngleZ = processedWords[5];
217 double accelX = processedWords[0] *
FREQ;
218 double accelY = processedWords[1] *
FREQ;
219 double accelZ = processedWords[2] *
FREQ;
220 double angleRateX = processedWords[3] *
FREQ;
221 double angleRateY = processedWords[4] *
FREQ;
222 double angleRateZ = processedWords[5] *
FREQ;
224 obs->dtime = 1.0 /
FREQ;
225 obs->dvel = { dVelX, dVelY, dVelZ };
226 obs->dtheta = { dAngleX, dAngleY, dAngleZ };
227 obs->p_acceleration = { accelX, accelY, accelZ };
228 obs->p_angularRate = { angleRateX, angleRateY, angleRateZ };
230 LOG_DATA(
"DATA({}): {}", lnSensor->name, obs->temperature.value());
233 if (
InsTime currentTime = util::time::GetCurrentInsTime();
234 !currentTime.
empty())
236 obs->insTime = currentTime;
240 else if (p.type() == uart::protocol::Packet::Type::TYPE_ASCII)
242 LOG_WARN(
"{}: Received an ASCII Async message: {}", lnSensor->name, p.datastr());
nlohmann::json json
json namespace
Text Help Marker (?) with Tooltip.
Data storage class for one VectorNavImu observation.
Litton LN-200 IMU Sensor.
Class to read out LN-200 Sensors.
Utility class for logging to console and file.
#define LOG_DEBUG
Debug information. Should not be called on functions which receive observations (spamming)
#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...
Keeps track of the current real/simulation time.
static std::string type()
Returns the type of the data class.
json save() const override
Saves the node into a json object.
void restore(const json &j) override
Restores the node from a json object.
void guiConfig() override
ImGui config window which is shown on double click.
Imu(const Imu &)=delete
Copy constructor.
The class is responsible for all time-related tasks.
constexpr bool empty() const
Checks if the Time object has a value.
json save() const override
Saves the node into a json object.
static std::string typeStatic()
String representation of the Class Type.
static std::string category()
String representation of the Class Category.
void restore(const json &j) override
Restores the node from a json object.
Ln200Sensor()
Default constructor.
vendor::ln::Ln200UartSensor _sensor
Sensor Object.
void guiConfig() override
ImGui config window which is shown on double click.
std::string type() const override
String representation of the Class Type.
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_LN_OBS
Flow (ImuObs)
void deinitialize() override
Deinitialize the node.
~Ln200Sensor() override
Destructor.
bool initialize() override
Initialize the node.
static constexpr uint8_t FREQ
IMU data frequency in Hz.
static void binaryAsyncMessageReceived(void *userData, uart::protocol::Packet &p, size_t index)
Callback handler for notifications of new asynchronous data packets received.
bool isInitialized() const
Checks if the node is initialized.
bool doDeinitialize(bool wait=false)
Asks the node worker to deinitialize the node.
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.
std::string name
Name of the Node.
bool _onlyRealTime
Whether the node can run in post-processing or only real-time.
bool _hasConfig
Flag if the config window should be shown.
static int baudrate2Selection(Baudrate baud)
Returns the guiSelection for the given baudrate.
int _selectedBaudrate
Baudrate for the sensor.
@ BAUDRATE_2000000
Baudrate with 2000000 symbols per second [Baud].
void restore(const json &j)
Restores the node from a json object.
Baudrate sensorBaudrate() const
Returns the Baudrate for the element Selected by the GUI.
json save() const
Saves the node into a json object.
void ApplyChanges()
Signals that there have been changes to the flow.