diagnostics_publisher.cpp
Go to the documentation of this file.
2 
4 {
5  nh.param("expected_frequency", expected_frequency, 10.0);
6  nh.param("max_latency", max_latency, 1.0);
7  nh.param("connection_lost_timeout", connection_lost_timeout, 10.0);
8 
9  ROS_INFO("Expected frequency for diagnostics : %.2f Hz", expected_frequency);
10  ROS_INFO("Max latency acceptable for diagnostics : %.3f s", max_latency);
11  ROS_INFO("Connection lost timeout : %.3f s", connection_lost_timeout);
12 
13  diagnosticsUpdater.add("status", this,
16  "imu topic", diagnosticsUpdater,
22 }
23 
24 void DiagnosticsPublisher::setHardwareID(const std::string& hwId)
25 {
27 }
28 
30 {
31  stdImuTopicDiagnostic->tick(stamp);
32 }
33 
35  const boost::optional<ixblue_stdbin_decoder::Data::INSSystemStatus>& systemStatus,
36  const boost::optional<ixblue_stdbin_decoder::Data::INSAlgorithmStatus>&
37  algorithmStatus)
38 {
40  lastSystemStatus = systemStatus;
41  lastAlgorithmStatus = algorithmStatus;
42 }
43 
45 {
47 }
48 
51 {
52  if(!lastAlgorithmStatus.is_initialized() || !lastSystemStatus.is_initialized())
53  {
54  status.summary(diagnostic_msgs::DiagnosticStatus::ERROR, "No data received yet");
55  }
56  else if((ros::SteadyTime::now() - lastMessageReceivedStamp).toSec() >
58  {
59  std::stringstream ss;
60  ss << "No more data for more than " << connection_lost_timeout << " s";
61  status.summary(diagnostic_msgs::DiagnosticStatus::ERROR, ss.str());
62  }
63  else
64  {
65  const std::bitset<32> algoStatus1{lastAlgorithmStatus->status1};
66  const std::bitset<32> algoStatus2{lastAlgorithmStatus->status2};
67  const std::bitset<32> algoStatus3{lastAlgorithmStatus->status3};
68  const std::bitset<32> algoStatus4{lastAlgorithmStatus->status4};
69 
70  const std::bitset<32> systemStatus1{lastSystemStatus->status1};
71  const std::bitset<32> systemStatus2{lastSystemStatus->status2};
72  const std::bitset<32> systemStatus3{lastSystemStatus->status3};
73 
74  status.add("algorithm_status_1", algoStatus1.to_string());
75  status.add("algorithm_status_2", algoStatus2.to_string());
76  status.add("algorithm_status_3", algoStatus3.to_string());
77  status.add("algorithm_status_4", algoStatus4.to_string());
78 
79  status.add("system_status_1", systemStatus1.to_string());
80  status.add("system_status_2", systemStatus2.to_string());
81  status.add("system_status_3", systemStatus3.to_string());
82 
83  if(systemStatus1.test(
84  ixblue_stdbin_decoder::Data::INSSystemStatus::Status1::SERIAL_IN_R_ERR))
85  {
86  status.summary(diagnostic_msgs::DiagnosticStatus::ERROR,
87  "Serial input error");
88  }
89  else if(systemStatus1.test(
90  ixblue_stdbin_decoder::Data::INSSystemStatus::Status1::INPUT_A_ERR))
91  {
92  // GNNS Input error on Atlans, Input A error on other systems
93  status.summary(diagnostic_msgs::DiagnosticStatus::ERROR,
94  "GNSS or Input A error");
95  }
96  // TODO other system status checks
98  WAIT_FOR_POSITION))
99  {
100  status.summary(diagnostic_msgs::DiagnosticStatus::ERROR,
101  "System is waiting for position");
102  }
103  else if(algoStatus1.test(
104  ixblue_stdbin_decoder::Data::INSAlgorithmStatus::Status1::ALIGNMENT))
105  {
106  status.summary(diagnostic_msgs::DiagnosticStatus::WARN,
107  "System in alignment, do not move");
108  }
109  else if(algoStatus1.test(ixblue_stdbin_decoder::Data::INSAlgorithmStatus::
110  Status1::FINE_ALIGNMENT))
111  {
112  status.summary(diagnostic_msgs::DiagnosticStatus::OK, "Fine alignment");
113  }
114  else if(algoStatus1.test(
115  ixblue_stdbin_decoder::Data::INSAlgorithmStatus::Status1::NAVIGATION))
116  {
117  status.summary(diagnostic_msgs::DiagnosticStatus::OK, "System in navigation");
118  }
119  else
120  {
121  status.summary(diagnostic_msgs::DiagnosticStatus::OK, "");
122  }
123  }
124 }
boost::optional< ixblue_stdbin_decoder::Data::INSSystemStatus > lastSystemStatus
void diagTimerCallback(const ros::TimerEvent &)
void summary(unsigned char lvl, const std::string s)
void setHardwareID(const std::string &hwid)
void add(const std::string &name, TaskFunction f)
void setHardwareID(const std::string &hwId)
static SteadyTime now()
boost::optional< ixblue_stdbin_decoder::Data::INSAlgorithmStatus > lastAlgorithmStatus
#define ROS_INFO(...)
bool param(const std::string &param_name, T &param_val, const T &default_val) const
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
void stdImuTick(const ros::Time &stamp)
void updateStatus(const boost::optional< ixblue_stdbin_decoder::Data::INSSystemStatus > &systemStatus, const boost::optional< ixblue_stdbin_decoder::Data::INSAlgorithmStatus > &algorithmStatus)
std::unique_ptr< diagnostic_updater::TopicDiagnostic > stdImuTopicDiagnostic
diagnostic_updater::Updater diagnosticsUpdater
void add(const std::string &key, const T &val)
ros::SteadyTime lastMessageReceivedStamp
DiagnosticsPublisher(ros::NodeHandle &nh)
void produceStatusDiagnostics(diagnostic_updater::DiagnosticStatusWrapper &status)


ixblue_ins_driver
Author(s): Adrien BARRAL , Laure LE BRETON
autogenerated on Wed Jan 27 2021 03:37:01