HiveMind
InterlocManager.h
Go to the documentation of this file.
1 #ifndef __INTERLOCMANAGER_H__
2 #define __INTERLOCMANAGER_H__
3 
4 #include <INotificationQueue.h>
5 #include <bsp/IInterlocManager.h>
6 #include <gazebo_msgs/ModelStates.h>
7 #include <logger/ILogger.h>
8 #include <ros/subscriber.h>
9 #include <tf2/LinearMath/Transform.h>
10 #include <tf2_ros/transform_listener.h>
11 
13  public:
14  InterlocManager(ILogger& logger, INotificationQueue<InterlocUpdate>& interlocUpdateQueue);
15  ~InterlocManager() override = default;
16 
17  void startInterloc() override;
18 
19  // Calib API is not needed in simulation. Can just ignore any calls to these functions
20  void setInterlocManagerState(InterlocStateDTO state) override;
21 
22  void configureTWRCalibration(uint16_t distanceCalibCm) override;
23 
24  void configureAngleCalibration(uint32_t numberOfFrames) override;
25 
27  interlocManagerStateChangeCallbackFunction_t callback, void* context) override;
28 
30  void* context) override;
31  void updateAngleCalculatorParameters(const ConfigureAngleParametersDTO& newParams) override;
32 
33  private:
35  ros::Subscriber m_sub;
37  std::map<uint16_t, geometry_msgs::TransformStamped> m_baseLinkToHiveBoardTransforms;
38 
39  tf2_ros::Buffer m_tfBuffer;
40  tf2_ros::TransformListener m_tfListener;
41 
42  INotificationQueue<InterlocUpdate>& m_interlocUpdateQueue;
43 
44  static tf2::Stamped<tf2::Transform> getHiveboardTf(
45  const geometry_msgs::Pose& poseWorldFrame,
46  const geometry_msgs::TransformStamped& hiveboardToRobotTf);
47  static double getDistance(const tf2::Transform& transform);
48  static double getRelativeOrientation(const tf2::Transform& transform);
49  static double getAngleOfArrival(const tf2::Transform& agentToAgentTransform);
50 
51  void gazeboUpdateCallback(const gazebo_msgs::ModelStates& msg);
52  std::optional<geometry_msgs::TransformStamped> getHiveBoardTransform(
53  const std::string& agentName);
54 };
55 
56 #endif //__INTERLOCMANAGER_H__
InterlocManager::m_tfBuffer
tf2_ros::Buffer m_tfBuffer
Definition: InterlocManager.h:39
IInterlocManager
Definition: IInterlocManager.h:16
InterlocManager
Definition: InterlocManager.h:12
InterlocManager::getHiveboardTf
static tf2::Stamped< tf2::Transform > getHiveboardTf(const geometry_msgs::Pose &poseWorldFrame, const geometry_msgs::TransformStamped &hiveboardToRobotTf)
Definition: InterlocManager.cpp:28
InterlocManager::m_logger
ILogger & m_logger
Definition: InterlocManager.h:34
interlocRawAngleDataCallbackFunction_t
void(* interlocRawAngleDataCallbackFunction_t)(void *instance, BspInterlocRawAngleData &rawAngleData)
Definition: IInterlocManager.h:13
interlocManagerStateChangeCallbackFunction_t
void(* interlocManagerStateChangeCallbackFunction_t)(void *instance, InterlocStateDTO previousState, InterlocStateDTO newState)
Definition: IInterlocManager.h:10
InterlocManager::updateAngleCalculatorParameters
void updateAngleCalculatorParameters(const ConfigureAngleParametersDTO &newParams) override
Definition: InterlocManager.cpp:168
InterlocManager::setInterlocManagerRawAngleDataCallback
void setInterlocManagerRawAngleDataCallback(interlocRawAngleDataCallbackFunction_t callback, void *context) override
Definition: InterlocManager.cpp:162
InterlocManager::setInterlocManagerState
void setInterlocManagerState(InterlocStateDTO state) override
Definition: InterlocManager.cpp:150
InterlocManager::m_sub
ros::Subscriber m_sub
Definition: InterlocManager.h:35
InterlocManager::setInterlocManagerStateChangeCallback
void setInterlocManagerStateChangeCallback(interlocManagerStateChangeCallbackFunction_t callback, void *context) override
Definition: InterlocManager.cpp:156
InterlocManager::getHiveBoardTransform
std::optional< geometry_msgs::TransformStamped > getHiveBoardTransform(const std::string &agentName)
Definition: InterlocManager.cpp:51
InterlocManager::configureAngleCalibration
void configureAngleCalibration(uint32_t numberOfFrames) override
Sets the number of frames to accumulate when in angle calibration mode.
Definition: InterlocManager.cpp:154
InterlocManager::m_tfListener
tf2_ros::TransformListener m_tfListener
Definition: InterlocManager.h:40
InterlocManager::m_baseLinkToHiveBoardTransforms
std::map< uint16_t, geometry_msgs::TransformStamped > m_baseLinkToHiveBoardTransforms
Definition: InterlocManager.h:37
InterlocManager::m_interlocRefreshDelayMs
uint m_interlocRefreshDelayMs
Definition: InterlocManager.h:36
ILogger
A logger class with basic logging capabilities.
Definition: ILogger.h:35
InterlocManager::~InterlocManager
~InterlocManager() override=default
InterlocManager::m_interlocUpdateQueue
INotificationQueue< InterlocUpdate > & m_interlocUpdateQueue
Definition: InterlocManager.h:42
InterlocManager::getAngleOfArrival
static double getAngleOfArrival(const tf2::Transform &agentToAgentTransform)
Definition: InterlocManager.cpp:47
InterlocManager::getRelativeOrientation
static double getRelativeOrientation(const tf2::Transform &transform)
IInterlocManager.h
InterlocManager::InterlocManager
InterlocManager(ILogger &logger, INotificationQueue< InterlocUpdate > &interlocUpdateQueue)
Definition: InterlocManager.cpp:13
InterlocManager::getDistance
static double getDistance(const tf2::Transform &transform)
Definition: InterlocManager.cpp:42
InterlocManager::gazeboUpdateCallback
void gazeboUpdateCallback(const gazebo_msgs::ModelStates &msg)
Definition: InterlocManager.cpp:69
InterlocManager::configureTWRCalibration
void configureTWRCalibration(uint16_t distanceCalibCm) override
Sets the targeted distance for calibration.
Definition: InterlocManager.cpp:152
ILogger.h
InterlocManager::startInterloc
void startInterloc() override
Dummy function to demonstrate working DW1000s.
Definition: InterlocManager.cpp:139