Heifu_diagnostic.cpp
Go to the documentation of this file.
2 
3 using namespace HD;
4 
6  std::string ns = ros::this_node::getNamespace();
7 
8  // Subscribers
9  subDiagnostic = n.subscribe("/diagnostics", 10, &Heifu_diagnostic::cbCheckGpsFix, this);
10 
11  // Publishers
12  pubGpsFixState = n.advertise < std_msgs::Int8 > (ns + "/g/f/m", 10);
13 
14  // Variables
15 
16  // Parameters
17  n.param<double>("paramNodeRate", paramNodeRate, 5.0);
18 }
19 
20 
22 
24  while (ros::ok()){
25  ros::spinOnce();
26  go.sleep();
27  }
28 }
29 
30 void Heifu_diagnostic::cbCheckGpsFix(const diagnostic_msgs::DiagnosticArrayConstPtr& msg){
31 
32  diagnostic_msgs::DiagnosticArray fixMsg = *msg;
33  int size = sizeof(fixMsg.status);
34  for(int i=0; i<size; i++){
35  if (fixMsg.status[i].message == str1)
36  {
37  int size2 = sizeof(fixMsg.status[i].values);
38  for (int j = 0; j <= size2; j++)
39  {
40  if (fixMsg.status[i].values[j].key == str2)
41  {
42  int fixType = stoi(fixMsg.status[i].values[j].value);
43  switch (fixType)
44  {
45  case 0:
46  gpsFixMode.data = 0;
47  ROS_INFO("FixType: No GPS");
48  break;
49  case 1:
50  gpsFixMode.data = 1;
51  ROS_INFO("FixType: No FIX");
52  break;
53  case 2:
54  gpsFixMode.data = 2;
55  //ros_utils::ROS_PRINT(ros_utils::BLUE_BOLD, "FixType: 2D FIX");
56  break;
57  case 3:
58  gpsFixMode.data = 3;
59  //ros_utils::ROS_PRINT(ros_utils::BLUE_BOLD, "FixType: 3D FIX");
60  break;
61  case 4:
62  gpsFixMode.data = 4;
63  //ros_utils::ROS_PRINT(ros_utils::BLUE_BOLD, "FixType: DGPS Fix");
64  break;
65  case 5:
66  gpsFixMode.data = 5;
67  //ros_utils::ROS_PRINT(ros_utils::BLUE_BOLD, "FixType: RTK FLOAT");
68  break;
69  case 6:
70  gpsFixMode.data = 6;
71  //ros_utils::ROS_PRINT(ros_utils::BLUE_BOLD, "FixType: RTK FIX");
72  break;
73  case 7:
74  gpsFixMode.data = 7;
75  //ros_utils::ROS_PRINT(ros_utils::BLUE_BOLD, "FixType: Static fixed");
76  break;
77  case 8:
78  gpsFixMode.data = 8;
79  //ros_utils::ROS_PRINT(ros_utils::BLUE_BOLD, "FixType: No PPP");
80  break;
81  default:
82  //ros_utils::ROS_PRINT(ros_utils::BLUE_BOLD, "FixType: NO INFO");
83  break;
84  }
86  break;
87  }
88  }
89 
90  }
91 
92  }
93 }
std_msgs::Int8 gpsFixMode
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ros::Subscriber subDiagnostic
void cbCheckGpsFix(const diagnostic_msgs::DiagnosticArrayConstPtr &msg)
def go()
bool param(const std::string &param_name, T &param_val, const T &default_val) const
void publish(const boost::shared_ptr< M > &message) const
ROSCPP_DECL const std::string & getNamespace()
#define ROS_INFO(...)
ROSCPP_DECL bool ok()
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
uint8_t size
bool sleep()
ROSCPP_DECL void spinOnce()
ros::Publisher pubGpsFixState


heifu_diagnostic
Author(s):
autogenerated on Tue Feb 2 2021 03:56:30