-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathqnode.h
More file actions
78 lines (62 loc) · 2.94 KB
/
qnode.h
File metadata and controls
78 lines (62 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef QNODE_H
#define QNODE_H
#include <QObject>
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"
#include "std_msgs/msg/int32.hpp"
#include "std_msgs/msg/float32.hpp"
#include "std_msgs/msg/bool.hpp"
#include "sensor_msgs/msg/nav_sat_fix.hpp"
#include <thread>
class QNode : public QObject {
Q_OBJECT
public:
QNode(int argc = 0, char** argv = nullptr, QObject *parent = nullptr);
// Designed so publisher and callback outputs are public,
// while subscribers are private.
rclcpp::Publisher<std_msgs::msg::Int32>::SharedPtr motorLeft_Pub;
rclcpp::Publisher<std_msgs::msg::Int32>::SharedPtr motorRight_Pub;
rclcpp::Publisher<std_msgs::msg::Bool>::SharedPtr safetyTrigger_Pub;
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pathList_Pub;
rclcpp::Publisher<std_msgs::msg::Bool>::SharedPtr guiConnection_Pub;
// Pub messages:
int motor_left = 0; // the motor data that is published and subscribed
int motor_right = 0;
int safety_trigger = true; // safety trigger to control safety_master if master allows (not in use)
bool ros_master_on = false;
bool connection_gui = true;
// Sub messages:
bool safety_master = true; // safety master to tell if motor lock is engaged
int heading = 0;
float latitude = 45.703547;
float longitude = 21.302171;
int sat_count = 0;
bool connection_robot = false;
float battery_voltage = 0.0;
int pitch = 0;
int roll = 0;
Q_SIGNALS:
// used to tell the backend that new ros data arrived and to update the gui
void msgSubscribed();
private:
rclcpp::Node::SharedPtr m_RosNode;
rclcpp::Subscription<std_msgs::msg::Int32>::SharedPtr m_Heading_Sub;
rclcpp::Subscription<std_msgs::msg::Bool>::SharedPtr m_Safety_Sub;
rclcpp::Subscription<std_msgs::msg::Int32>::SharedPtr m_MotorLeft_Sub;
rclcpp::Subscription<std_msgs::msg::Int32>::SharedPtr m_MotorRight_Sub;
rclcpp::Subscription<sensor_msgs::msg::NavSatFix>::SharedPtr m_GPS_Sub;
rclcpp::Subscription<std_msgs::msg::Bool>::SharedPtr m_RobotConnection_Sub;
rclcpp::Subscription<std_msgs::msg::Float32>::SharedPtr m_BatteryVoltage_sub;
rclcpp::Subscription<std_msgs::msg::Int32>::SharedPtr m_Pitch_Sub;
rclcpp::Subscription<std_msgs::msg::Int32>::SharedPtr m_Roll_Sub;
void m_Heading_Callback(const std_msgs::msg::Int32::SharedPtr msg);
void m_Safety_Callback(const std_msgs::msg::Bool::SharedPtr msg);
void m_MotorLeft_Callback(const std_msgs::msg::Int32::SharedPtr msg);
void m_MotorRight_Callback(const std_msgs::msg::Int32::SharedPtr msg);
void m_GPS_Callback(const sensor_msgs::msg::NavSatFix::SharedPtr msg);
void m_RobotConnection_Callback(const std_msgs::msg::Bool::SharedPtr msg);
void m_BatteryVoltage_Callback(const std_msgs::msg::Float32::SharedPtr msg);
void m_Pitch_Callback(const std_msgs::msg::Int32::SharedPtr msg);
void m_Roll_Callback(const std_msgs::msg::Int32::SharedPtr msg);
};
#endif // QNODE_H