HiveMind
ILogger.h
Go to the documentation of this file.
1 #ifndef __ILOGGER_H_
2 #define __ILOGGER_H_
3 
4 #include <cstdarg>
5 
9 enum class LogLevel {
11  Debug = 0,
13  Info = 1,
15  Warn = 2,
17  Error = 3
18 };
19 
23 enum class LogRet {
25  Ok = 0,
27  LowLevel = 1,
29  Error = 2
30 };
31 
35 class ILogger {
36  public:
37  virtual ~ILogger() = default;
38 
46  virtual LogRet log(LogLevel level, const char* format, ...) = 0;
47 
55  virtual LogRet log(LogLevel level, const char* format, va_list args) = 0;
56 };
57 
58 #endif // __ILOGGER_H_
IInterlocManager
Definition: IInterlocManager.h:16
Interloc::processPositionUpdate
void processPositionUpdate(const InterlocUpdate &positionUpdate)
Definition: Interloc.cpp:39
Interloc::m_positionUpdateInputQueue
INotificationQueue< InterlocUpdate > & m_positionUpdateInputQueue
Definition: Interloc.h:45
PositionsTable
Definition: IInterloc.h:10
LogLevel::Error
@ Error
LogLevel::Debug
@ Debug
IBSP::getUUId
virtual uint16_t getUUId() const =0
Returns the unique id associated with the board.
Interloc::dumpUpdatesHistory
void dumpUpdatesHistory()
Definition: Interloc.cpp:120
ConnectionState::Error
@ Error
LogRet::LowLevel
@ LowLevel
IInterlocManager::configureTWRCalibration
virtual void configureTWRCalibration(uint16_t distanceCalibCm)=0
Sets the targeted distance for calibration.
Interloc::isLineOfSight
bool isLineOfSight(uint16_t robotId) const override
Tells if a robot is in line of sight.
Definition: Interloc.cpp:29
LogRet
LogRet
The return value of the logger.
Definition: ILogger.h:23
InterlocContainer::getInterlocUpdateOutputQueue
ThreadSafeQueue< uint16_t > & getInterlocUpdateOutputQueue()
get interloc position update msg queu
Definition: InterlocContainer.cpp:29
Interloc::m_positionsTable
PositionsTable m_positionsTable
Definition: Interloc.h:43
InterlocUpdate::m_isInLineOfSight
std::optional< bool > m_isInLineOfSight
Definition: InterlocUpdate.h:20
BSPContainer.h
RelativePosition::m_angleRealMean
float m_angleRealMean
Definition: RelativePosition.h:19
InterlocUpdate::m_distance
std::optional< float > m_distance
Distance in meters.
Definition: InterlocUpdate.h:13
ILogger::log
virtual LogRet log(LogLevel level, const char *format,...)=0
Logs if the provided level is higher than the current log level (Thread-safe)
IInterlocMessageHandler
Definition: IInterlocMessageHandler.h:6
IInterlocMessageHandler::sendInterlocDump
virtual bool sendInterlocDump(InterlocUpdate *updatesHistory, uint8_t updatesLength)=0
Sends a history of interloc updates back to the host.
LoggerContainer.h
InterlocMessageHandler::handleMessage
bool handleMessage(const MessageDTO &dto)
Definition: InterlocMessageHandler.cpp:47
InterlocMessageHandler::constructRawDataMessage
static InterlocRawAngleDataDTO constructRawDataMessage(BspInterlocRawAngleData &data, uint32_t fromId, uint8_t numFrames)
Definition: InterlocMessageHandler.cpp:164
RelativePosition::m_isInLineOfSight
bool m_isInLineOfSight
Definition: RelativePosition.h:22
Interloc::getRobotPosition
std::optional< RelativePosition > getRobotPosition(uint16_t robotId) const override
Returns the last known relative position of a given robot.
Definition: Interloc.cpp:19
InterlocContainer::getInterlocMessageHandler
IInterlocMessageHandler & getInterlocMessageHandler()
Definition: InterlocContainer.cpp:19
InterlocMessageHandler::getDumpEnabled
bool getDumpEnabled() const override
Retrieves a flag to know if data dumps to the host should be done or not.
Definition: InterlocMessageHandler.cpp:202
BspInterlocRawAngleData
Definition: BspInterlocAngleRawData.h:24
InterlocMessageHandler::m_updateDtoArray
std::array< GetNeighborResponseDTO, InterlocDumpDTO::MAX_UPDATES_SIZE > m_updateDtoArray
Definition: InterlocMessageHandler.h:40
BittyBuzzUserFunctions::delay
void delay()
wait for a certain delay Signature delay(arg1) Warning this function make the whole VM sleep which ca...
Definition: BittyBuzzUserFunctions.cpp:327
InterlocContainer.h
ALPHA
#define ALPHA
Definition: Interloc.cpp:4
LogLevel
LogLevel
The log level used for the logger.
Definition: ILogger.h:9
InterlocMessageHandler::m_logger
ILogger & m_logger
Definition: InterlocMessageHandler.h:32
Interloc::Interloc
Interloc(ILogger &logger, IInterlocManager &interlocManager, IInterlocMessageHandler &messageHandler, ICircularQueue< uint16_t > &positionUpdateOutputQueue, INotificationQueue< InterlocUpdate > &positionUpdateInputQueue)
Definition: Interloc.cpp:6
Interloc::m_updateHistoryIdx
uint8_t m_updateHistoryIdx
Definition: Interloc.h:48
InterlocMessageHandler::sendInterlocDump
bool sendInterlocDump(InterlocUpdate *updatesHistory, uint8_t updatesLength) override
Sends a history of interloc updates back to the host.
Definition: InterlocMessageHandler.cpp:204
IInterlocManager::setInterlocManagerState
virtual void setInterlocManagerState(InterlocStateDTO state)=0
INVALID_INTERLOC_FLOAT
#define INVALID_INTERLOC_FLOAT
Definition: InterlocMessageHandler.cpp:6
InterlocContainer::getInterlocUpdateInputQueue
INotificationQueue< InterlocUpdate > & getInterlocUpdateInputQueue()
Gets a queue in which to insert raw position updates from the BSP layer.
Definition: InterlocContainer.cpp:37
InterlocMessageHandler::m_inputQueue
ICircularQueue< MessageDTO > & m_inputQueue
Definition: InterlocMessageHandler.h:35
InterlocMessageHandler.h
MessageHandlerContainer::getRemoteMsgQueue
NotificationQueue< MessageDTO > & getRemoteMsgQueue()
get the remote message queue
Definition: MessageHandlerContainer.cpp:57
InterlocMessageHandler
Definition: InterlocMessageHandler.h:13
RelativePosition::m_angle
float m_angle
Angle of other agent in current agent frame (in degrees)
Definition: RelativePosition.h:17
InterlocMessageHandler::rawAngleDataCallbackStatic
static void rawAngleDataCallbackStatic(void *context, BspInterlocRawAngleData &data)
Definition: InterlocMessageHandler.cpp:192
InterlocMessageHandler::stateChangeCallback
void stateChangeCallback(InterlocStateDTO previousState, InterlocStateDTO newState)
Definition: InterlocMessageHandler.cpp:111
LogLevel::Warn
@ Warn
BSPContainer::getInterlocManager
IInterlocManager & getInterlocManager()
Returns an instance of the interloc manager.
Definition: BSPContainer.cpp:24
InterlocUpdate::m_angleOfArrival
std::optional< float > m_angleOfArrival
Angle of the distant agent in the frame of the current agent (in degrees)
Definition: InterlocUpdate.h:18
InterlocMessageHandler::m_dumpsEnabled
bool m_dumpsEnabled
Definition: InterlocMessageHandler.h:43
PositionsTable::m_positionsLength
uint16_t m_positionsLength
Definition: IInterloc.h:12
InterlocMessageHandler::m_remoteQueue
ICircularQueue< MessageDTO > & m_remoteQueue
Definition: InterlocMessageHandler.h:37
IBSP
Definition: IBSP.h:6
InterlocUpdate::m_robotId
uint16_t m_robotId
Definition: InterlocUpdate.h:8
InterlocMessageHandler::ensureSendMessage
void ensureSendMessage(MessageDTO &msg)
Definition: InterlocMessageHandler.cpp:156
LogLevel::Info
@ Info
IInterlocManager::updateAngleCalculatorParameters
virtual void updateAngleCalculatorParameters(const ConfigureAngleParametersDTO &newParams)=0
InterlocUpdate
Definition: InterlocUpdate.h:7
Interloc::process
void process()
Spins the interloc task checking if any updates happened. Processing them and pushing update values t...
Definition: Interloc.cpp:98
IInterlocManager::configureAngleCalibration
virtual void configureAngleCalibration(uint32_t numberOfFrames)=0
Sets the number of frames to accumulate when in angle calibration mode.
LoggerContainer::getLogger
Logger & getLogger()
Return a reference to the global logger.
Definition: LoggerContainer.cpp:5
IInterlocMessageHandler::getDumpEnabled
virtual bool getDumpEnabled() const =0
Retrieves a flag to know if data dumps to the host should be done or not.
InterlocMessageHandler::stateChangeCallbackStatic
static void stateChangeCallbackStatic(void *context, InterlocStateDTO previousState, InterlocStateDTO newState)
Definition: InterlocMessageHandler.cpp:197
Math::atan2
float atan2(float y, float x)
calculate the arc of x/y
Definition: Math.cpp:20
Interloc::m_messageHandler
IInterlocMessageHandler & m_messageHandler
Definition: Interloc.h:41
InterlocMessageHandler::handleStateChangeMessage
bool handleStateChangeMessage(const SetInterlocStateDTO dto) const
Definition: InterlocMessageHandler.cpp:75
Interloc::m_logger
ILogger & m_logger
Definition: Interloc.h:39
Interloc::m_updatesHistory
std::array< InterlocUpdate, InterlocDumpDTO::MAX_UPDATES_SIZE > m_updatesHistory
Definition: Interloc.h:47
ILogger
A logger class with basic logging capabilities.
Definition: ILogger.h:35
BspInterlocRawAngleData::m_framesLength
uint32_t m_framesLength
Definition: BspInterlocAngleRawData.h:26
InterlocMessageHandler::getQueueForDestination
ICircularQueue< MessageDTO > & getQueueForDestination(uint16_t destinationId) const
Definition: InterlocMessageHandler.cpp:67
BSPContainer::getBSP
IBSP & getBSP()
Returns an instance of the platform dependent BSP.
Definition: BSPContainer.cpp:13
InterlocContainer::getInterloc
IInterloc & getInterloc()
Definition: InterlocContainer.cpp:12
BspInterlocRawAngleData::m_frames
std::array< BspInterlocFrameAngleRawData, MAX_ANGLE_FRAMES > m_frames
Definition: BspInterlocAngleRawData.h:27
Interloc::m_positionUpdateOutputQueue
ICircularQueue< uint16_t > & m_positionUpdateOutputQueue
Definition: Interloc.h:44
RelativePosition
Definition: RelativePosition.h:6
Interloc.h
InterlocUpdate::m_resetDumps
bool m_resetDumps
Definition: InterlocUpdate.h:22
MessageHandlerContainer::getInterlocMsgQueue
NotificationQueue< MessageDTO > & getInterlocMsgQueue()
get the interloc message queue
Definition: MessageHandlerContainer.cpp:70
InterlocMessageHandler::processMessage
bool processMessage() override
Processes the next message in the queue.
Definition: InterlocMessageHandler.cpp:29
Interloc
Definition: Interloc.h:18
InterlocMessageHandler::m_hostQueue
ICircularQueue< MessageDTO > & m_hostQueue
Definition: InterlocMessageHandler.h:36
IInterloc
Definition: IInterloc.h:15
InterlocMessageHandler::rawAngleDataCallback
void rawAngleDataCallback(BspInterlocRawAngleData &data)
Definition: InterlocMessageHandler.cpp:127
MessageHandlerContainer::getHostMsgQueue
NotificationQueue< MessageDTO > & getHostMsgQueue()
get the host message queue
Definition: MessageHandlerContainer.cpp:44
IInterlocManager::setInterlocManagerRawAngleDataCallback
virtual void setInterlocManagerRawAngleDataCallback(interlocRawAngleDataCallbackFunction_t callback, void *context)=0
PositionsTable::m_positions
std::array< RelativePosition, MAX_AGENTS_IN_SWARM > m_positions
Definition: IInterloc.h:11
Interloc::getRobotArrayIndex
std::optional< uint8_t > getRobotArrayIndex(uint16_t robotId) const
Definition: Interloc.cpp:56
InterlocMessageHandler::m_messageSourceId
uint16_t m_messageSourceId
Definition: InterlocMessageHandler.h:42
RelativePosition::m_robotId
uint16_t m_robotId
Definition: RelativePosition.h:7
InterlocMessageHandler::m_interlocPositionUpdateQueue
INotificationQueue< InterlocUpdate > & m_interlocPositionUpdateQueue
Definition: InterlocMessageHandler.h:38
InterlocMessageHandler::m_bsp
IBSP & m_bsp
Definition: InterlocMessageHandler.h:34
InterlocMessageHandler::handleConfigurationMessage
bool handleConfigurationMessage(const InterlocConfigurationDTO &dto)
Definition: InterlocMessageHandler.cpp:85
InterlocMessageHandler::InterlocMessageHandler
InterlocMessageHandler(ILogger &logger, IInterlocManager &interlocManager, IBSP &bsp, ICircularQueue< MessageDTO > &inputQueue, ICircularQueue< MessageDTO > &hostQueue, ICircularQueue< MessageDTO > &remoteQueue, INotificationQueue< InterlocUpdate > &interlocPositionUpdateQueue)
Definition: InterlocMessageHandler.cpp:8
Interloc::getPositionsTable
const PositionsTable & getPositionsTable() const override
Returns the position table for all robots in the swarm.
Definition: Interloc.cpp:96
RelativePosition::m_angleImaginaryMean
float m_angleImaginaryMean
Definition: RelativePosition.h:20
Interloc::updateRobotPosition
static void updateRobotPosition(RelativePosition &positionToUpdate, InterlocUpdate update)
Definition: Interloc.cpp:67
MAX_AGENTS_IN_SWARM
#define MAX_AGENTS_IN_SWARM
Template file used by CMake to provide default or user-provided values for the settings.
Definition: InterlocSettings.in.h:10
DeviceState::Ok
@ Ok
IInterlocManager::setInterlocManagerStateChangeCallback
virtual void setInterlocManagerStateChangeCallback(interlocManagerStateChangeCallbackFunction_t callback, void *context)=0
Interloc::filterValue
static constexpr float filterValue(float oldValue, float newValue, float alpha)
Definition: Interloc.cpp:130
ILogger::~ILogger
virtual ~ILogger()=default
BittyBuzzMathFunctions::cos
void cos()
Calculates the cosine Signature cos(arg1)
Definition: BittyBuzzMathFunctions.cpp:181
RelativePosition::m_distance
float m_distance
Distance in meters.
Definition: RelativePosition.h:12
gc_interlocPosUpdateMaxSize
constexpr uint16_t gc_interlocPosUpdateMaxSize
Definition: InterlocContainer.cpp:10
MessageHandlerContainer.h
BittyBuzzMathFunctions::sin
void sin()
Calculates the sine Signature sin(arg1)
Definition: BittyBuzzMathFunctions.cpp:168
InterlocMessageHandler::m_interlocManager
IInterlocManager & m_interlocManager
Definition: InterlocMessageHandler.h:33