Galaxis Codebase  1.0.0
Team Galaxis software stack for the Carolo Cup 2023 - ROS2 based software
MMNode Class Reference

#include <MMNode.hpp>

Inheritance diagram for MMNode:
Collaboration diagram for MMNode:

Public Member Functions

 MMNode ()
 
 ~MMNode ()
 

Static Public Member Functions

static void on_mm_callback ()
 

Static Public Attributes

static MMNode * m_instancePtr = nullptr
 

Private Member Functions

void publish_data (const GPSDataType::SharedPtr msg)
 

Private Attributes

rclcpp::Publisher< GPSDataType >::SharedPtr m_positionPubSPtr
 
rclcpp::Subscription< ServiceStateType >::SharedPtr m_serviceStateSubSPtr
 
uint8_t service_state_ = 0
 
std::string node_name_
 
MarvelmindHedge * m_hedgePtr
 

Detailed Description

Definition at line 15 of file MMNode.hpp.

Constructor & Destructor Documentation

◆ MMNode()

MMNode::MMNode ( )

Definition at line 6 of file MMNode.cpp.

6  :
7  Node("MarvelmindNode") {
8 
9  m_instancePtr = this;
10  node_name_ = "MarvelmindNode";
11 
12  galaxis::ros::create_publisher(this, m_positionPubSPtr);
13 
16  m_hedgePtr->verbose = true;
18 
19  if(!m_hedgePtr) {
20  return;
21  }
22 
25 
26  RCLCPP_INFO(this->get_logger(), "Node initialized, starting operation.");
27 }

References MarvelmindHedge::anyInputPacketCallback, createMarvelmindHedge(), DEFAULT_TTY_FILENAME, m_hedgePtr, m_instancePtr, m_positionPubSPtr, node_name_, on_mm_callback(), printStationaryBeaconsPositionsFromMarvelmindHedge(), startMarvelmindHedge(), MarvelmindHedge::ttyFileName, and MarvelmindHedge::verbose.

Here is the call graph for this function:

◆ ~MMNode()

MMNode::~MMNode ( )

Definition at line 29 of file MMNode.cpp.

29  {
30  m_instancePtr = nullptr;
31 }

References m_instancePtr.

Member Function Documentation

◆ on_mm_callback()

void MMNode::on_mm_callback ( )
static

Definition at line 33 of file MMNode.cpp.

33  {
34  auto msg = std::make_shared<GPSDataType>();
35 
36  if(MMNode::m_instancePtr == nullptr) {
37  std::cout << "m_instancePtr is nullptr" << std::endl;
39  }
40 
41  FusionIMUValue fusion;
42  PositionValue position;
43 
46 
47  msg->gps_pos.x = static_cast<float>(position.x) / 1000.f;
48  msg->gps_pos.y = static_cast<float>(position.y) / 1000.f;
49 
50  msg->fus_pos.x = static_cast<float>(fusion.x) / 1000.f;
51  msg->fus_pos.y = static_cast<float>(fusion.y) / 1000.f;
52 
53  msg->timestamp = fusion.timestamp;
54 
55  RCLCPP_INFO(m_instancePtr->get_logger(), "Publish position: %f , %f", msg->gps_pos.x, msg->gps_pos.y);
56  RCLCPP_INFO(m_instancePtr->get_logger(), "Publish fusion position: %f , %f", msg->fus_pos.x, msg->fus_pos.y);
57 
59 }

References getFusionIMUFromMarvelmindHedge(), getPositionFromMarvelmindHedge(), m_hedgePtr, m_instancePtr, publish_data(), FusionIMUValue::timestamp, PositionValue::x, FusionIMUValue::x, PositionValue::y, and FusionIMUValue::y.

Referenced by MMNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ publish_data()

void MMNode::publish_data ( const GPSDataType::SharedPtr  msg)
private

Definition at line 61 of file MMNode.cpp.

61  {
62  if(p_msgSPtr == nullptr) {
63  RCLCPP_ERROR(this->get_logger(), "p_msgSPtr is nullptr");
65  }
66 
67  auto msgUPtr = std::make_unique<GPSDataType>(*p_msgSPtr);
68 
69  m_positionPubSPtr->publish(std::move(msgUPtr));
70 }

References m_positionPubSPtr.

Referenced by on_mm_callback().

Here is the caller graph for this function:

Member Data Documentation

◆ m_hedgePtr

MarvelmindHedge* MMNode::m_hedgePtr
private

Definition at line 22 of file MMNode.hpp.

Referenced by MMNode(), and on_mm_callback().

◆ m_instancePtr

MMNode * MMNode::m_instancePtr = nullptr
static

Definition at line 30 of file MMNode.hpp.

Referenced by MMNode(), on_mm_callback(), and ~MMNode().

◆ m_positionPubSPtr

rclcpp::Publisher<GPSDataType>::SharedPtr MMNode::m_positionPubSPtr
private

Definition at line 17 of file MMNode.hpp.

Referenced by MMNode(), and publish_data().

◆ m_serviceStateSubSPtr

rclcpp::Subscription<ServiceStateType>::SharedPtr MMNode::m_serviceStateSubSPtr
private

Definition at line 18 of file MMNode.hpp.

◆ node_name_

std::string MMNode::node_name_
private

Definition at line 21 of file MMNode.hpp.

Referenced by MMNode().

◆ service_state_

uint8_t MMNode::service_state_ = 0
private

Definition at line 20 of file MMNode.hpp.


The documentation for this class was generated from the following files:
MarvelmindHedge::anyInputPacketCallback
void(* anyInputPacketCallback)()
Definition: marvelmind.h:122
getFusionIMUFromMarvelmindHedge
bool getFusionIMUFromMarvelmindHedge(struct MarvelmindHedge *hedge, struct FusionIMUValue *fusionIMU)
Definition: marvelmind.c:1002
FusionIMUValue::y
int32_t y
Definition: marvelmind.h:42
MarvelmindHedge::verbose
bool verbose
Definition: marvelmind.h:112
createMarvelmindHedge
struct MarvelmindHedge * createMarvelmindHedge()
Definition: marvelmind.c:688
galaxis::Errors::POINTER_ERROR
Definition: Errors.hpp:18
FusionIMUValue::x
int32_t x
Definition: marvelmind.h:41
MMNode::publish_data
void publish_data(const GPSDataType::SharedPtr msg)
Definition: MMNode.cpp:61
MMNode::m_instancePtr
static MMNode * m_instancePtr
Definition: MMNode.hpp:30
FusionIMUValue
Definition: marvelmind.h:40
PositionValue::y
int32_t y
Definition: marvelmind.h:12
getPositionFromMarvelmindHedge
bool getPositionFromMarvelmindHedge(struct MarvelmindHedge *hedge, struct PositionValue *position)
Definition: marvelmind.c:816
MMNode::m_positionPubSPtr
rclcpp::Publisher< GPSDataType >::SharedPtr m_positionPubSPtr
Definition: MMNode.hpp:17
PositionValue
Definition: marvelmind.h:9
MarvelmindHedge::ttyFileName
const char * ttyFileName
Definition: marvelmind.h:94
printStationaryBeaconsPositionsFromMarvelmindHedge
void printStationaryBeaconsPositionsFromMarvelmindHedge(struct MarvelmindHedge *hedge, bool onlyNew)
Definition: marvelmind.c:888
DEFAULT_TTY_FILENAME
#define DEFAULT_TTY_FILENAME
Definition: marvelmind.h:179
MMNode::node_name_
std::string node_name_
Definition: MMNode.hpp:21
startMarvelmindHedge
void startMarvelmindHedge(struct MarvelmindHedge *hedge)
Definition: marvelmind.c:718
FusionIMUValue::timestamp
uint32_t timestamp
Definition: marvelmind.h:58
MMNode::m_hedgePtr
MarvelmindHedge * m_hedgePtr
Definition: MMNode.hpp:22
PositionValue::x
int32_t x
Definition: marvelmind.h:12
MMNode::on_mm_callback
static void on_mm_callback()
Definition: MMNode.cpp:33