41 for (
auto i = 0; i < number_of_sensors; ++i)
43 if (known_sensors[i].InterfaceSensorId_u16 == TargetSensor_u16)
50 ROS_ERROR(
"Requested target sensor ID (%d) is not known on bus!", TargetSensor_u16);
57 ss <<
"Current sensor settings:\n";
60 ss <<
"FixedFrameRate_b: " << FixedFrameRate_b;
63 ss <<
"\nGetParameterTransducerNumOfPulses_u8: " 65 ss <<
"\nGetParameterSignalProcessingTemperature_f: " 67 ss <<
"\nGetParameterSignalProcessingHumidity_u8: " 70 ss <<
"\nGetParameterSystemMCUTemperature_f: " 77 constexpr
auto max_id_index = 2;
78 for (
auto i = 0; i <= max_id_index; ++i)
81 ss <<
"\nUniqueID_cp[" << i <<
"]: ";
86 if (j < (UID_SIZE - 1))
106 std::stringstream ss;
108 ss <<
"[" << std::to_string(known_sensors[0].InterfaceSensorId_u16);
109 for (
auto i = 1; i < number_of_sensors_on_bus; ++i)
113 ss << std::to_string(known_sensors[i].InterfaceSensorId_u16);
117 ROS_INFO(
"%u known sensors on bus. IDs: %s", number_of_sensors_on_bus, ss.str().c_str());
126 std::stringstream ss;
130 return std::to_string(version.
major) +
"." + std::to_string(version.
minor) +
"." +
131 std::to_string(version.
hotfix);
135 ss <<
"Bootloader: " << to_string(version) <<
",\n";
137 ss <<
"App: " << to_string(version) <<
",\n";
139 ss <<
"Hardware: " << to_string(version) <<
",\n";
141 ss <<
"Sig Pro Lib: " << to_string(version) <<
",\n";
143 ss <<
"Comms Lib: " << to_string(version);
150 if (session ==
nullptr)
152 ROS_WARN(
"LogSessionData: Received request to log session == nullptr!");
155 auto to_string = [](
bool b) {
return b ?
"true" :
"false"; };
158 "LogSessionData:\nSessionActive_b:\t%s,\nsenderId_u16:\t\t%d,\nNumberOfPoints_u8:" 160 "d\nNoiseLevel_u16:\t\t%d\nNearFieldPoint_b:\t%" 167 std::stringstream ss;
169 ss <<
"1D Points [VectorLength, Intensity], " << std::to_string(session->
NumberOf1DPoints)
182 ss.str(std::string());
183 ss <<
"3D Points [x, y, z, intensity], " << std::to_string(session->
NumberOf3DPoints)
188 ss <<
"\n\t" << i <<
": [" << std::to_string(session->
Point3D_tp[i].
X_i16)
208 ROS_DEBUG(
"Successfully configured sensor log level (%d)!", log_level);
212 ROS_WARN(
"Failed to configure sensor log level (%d)!", log_level);
221 std::stringstream ss;
222 ss <<
"Log-Msg Callback from Sender " << SenderId_u16 <<
": " << message_buffer;
224 const auto log_msg = ss.str();
void InitCanInterface(const std::string &can_device, int data_rate=1000000)
Inits the driver on given can_device with hard-coded data rate.
void LogKnownSensors(double log_interval=3.0)
Get currently known sensors from driver and log to ROS console every log_interval seconds...
SensorState_t GetParameterSystemSensorState_t()
Blocking Request to read the Sensor State from current sensor.
ResetReason_t GetParameterSystemResetReason_t()
Blocking Request to read the last Reset Reason from current sensor.
void LogMsgCallback(uint16_t SenderId_u16, uint8_t *ReceivedPayload_pu8)
Callback handling log messages from sensor.
void DeinitInterface(CommsInterfaceType_t Interface_t)
Instruction to deinit the specified interface type.
uint8_t GetParameterTransducerVolume_u8()
Blocking Request to read the current Transducer Volume from current sensor.
UID_t GetParameterSystemUniqueID_t(uint8_t Index_u8)
Blocking Request to read the Unique ID from current sensor.
Version_t RequestVersion_t(VersionByte_t TargetComponent_t)
Blocking - Request transmition of the current version of selected component from selected sensor...
uint8_t GetParameterTransducerNumOfPulses_u8()
Blocking Request to read the current Transducer Number of Pulses from current sensor.
LogLevel_t GetParameterSystemLogLevel_t()
Blocking Request to read the current System Log Level from current sensor.
Sensor_t * GetKnownSensors()
Returns pointer to array containing all known sensors. With GetNumberOfKnownSensors() users can get l...
uint8_t NumberOfPoints_u8
float GetParameterSignalProcessingTemperature_f()
Blocking Request to read the current Transducer Temperature setting from current sensor.
auto SetTargetSensor(uint16_t TargetSensor_u16) -> bool
Checks if TargetSensor_u16 is known and sets current target accordingly.
SessionState_t SessionState
#define LOGGING_SEVERITY_BYTE
uint16_t VectorLength_u16
uint16_t WaitForSessionEnd()
Blocking Function call to wait for SessionEnd Payload.
uint8_t GetNumberOfKnownSensors()
Returns number of known sensors. With GetKnownSensors() users an pointer to an array containing the I...
uint8_t GetParameterADCFixedFrameRate_u8()
Blocking Request to read the current set ADC-Framerate from current sensor.
void LogSettings()
Read current configuration from sensor and log to ROS console.
#define MAX_PARSED_LOG_MESSAGE_LEN
void InitUARTInterface(const std::string &uart_device, int data_rate=0010002)
Inits the driver on given uart_device with hard-coded data rate.
bool RequestMeasurement()
Send's a request to start a new measurement.
bool SetParameterSystemLogLevel(LogLevel_t LogLevel_t)
Blocking Request to set the Loglevel for current target sensor.
uint8_t GetParameterSignalProcessingHumidity_u8()
Blocking Request to read the current Transducer Humidity setting from current sensor.
void LogVersions()
Read all version information (such as bootloader version, app versionetc.) from sensor and log to ROS...
Sensor_Session_t * GetSessionData(uint16_t Sender_u16)
Interface function to query current session-data (ongoing and closed session)
void ParseLogMessageToText(char *Output_p8, uint16_t SenderId_u16, const uint8_t *ReceivedPayload_pu8)
Parses log messages into human readable text.
auto RequestSessionData() -> Sensor_Session_t *
Requesting single shot measurement from first sensor in known sensors array.
void InitInterface(char *InterfaceName, uint32_t DataRate_u32, CommsInterfaceType_t Interface_t)
Instruction to initialize the specified interface with the specified bit rate. Will also initialize t...
Point3D_t Point3D_tp[MAX_NUMBER_OF_POINTS_PER_SESSION]
#define ROS_WARN_STREAM(args)
#define ROS_DEBUG_STREAM(args)
uint16_t GetParameterSystemNodeID_u16()
Blocking Request to read the current NodeID setting from current sensor.
bool GetParameterADCUseFixedFrameRate_b()
Blocking Request to read the "Use fixed framerate" value from current sensor.
#define ROS_INFO_STREAM(args)
void DeinitCanInterface()
void DeinitUARTInterface()
void ConfigureSensorLogMessages(void(*Callback)(uint16_t Sender_u16, uint8_t *ReceivedPayload_pu8), LogLevel_t log_level)
Sets log level with the sensor and registers callback.
#define ROS_ERROR_STREAM(args)
void RegisterLogMsgCallback(void(*Callback)(uint16_t Sender_u16, uint8_t *ReceivedPayload_pu8))
Interface function to register a callback function that is called whenever a Logmessage Payload is re...
auto toHexString(const uint16_t i) -> std::string
Convert given i to hex string.
Point1D_t Point1D_tp[MAX_NUMBER_OF_POINTS_PER_SESSION]
float GetParameterSystemMCUTemperature_f()
Blocking Request to read the current MCU Temperature from current sensor.
void LogSessionData(const Sensor_Session_t *session)
Log given session data to ROS concole.
SensorMode_t GetParameterSystemSensorMode_t()
Blocking Request to read the Sensor Mode from current sensor.