Galaxis Codebase  1.0.0
Team Galaxis software stack for the Carolo Cup 2023 - ROS2 based software
MMNode.cpp
Go to the documentation of this file.
1 #include <MMNode.hpp>
3 
5 
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 }
28 
30  m_instancePtr = nullptr;
31 }
32 
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 }
60 
61 void MMNode::publish_data(const GPSDataType::SharedPtr p_msgSPtr) {
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 }
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
MMNode::MMNode
MMNode()
Definition: MMNode.cpp:6
MMNode::~MMNode
~MMNode()
Definition: MMNode.cpp:29
MarvelmindHedge::verbose
bool verbose
Definition: marvelmind.h:112
node_ros_pubsub_wrapper.hpp
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
MMNode.hpp
MMNode
Definition: MMNode.hpp:15
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