32 #include "diagnostic_msgs/SelfTest.h" 67 ROS_INFO(
"Doing preparation stuff before we run our test.\n");
68 status.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"Pretest completed successfully.");
77 bool lookup_successful =
true;
79 if (lookup_successful)
81 status.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"ID Lookup successful");
85 status.
summary(diagnostic_msgs::DiagnosticStatus::ERROR,
"ID Lookup failed");
91 status.
summary(diagnostic_msgs::DiagnosticStatus::ERROR,
"Reporting an error");
98 status.
add(
"some value", some_val);
99 status.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"We successfully changed the value.");
104 if (some_val == 42.0)
106 status.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"We observed the change in value");
110 status.
summaryf(diagnostic_msgs::DiagnosticStatus::ERROR,
"We failed to observe the change in value, it is currently %f.", some_val);
116 ROS_INFO(
"Doing cleanup stuff after we run our test.\n");
117 status.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"Posttest completed successfully.");
void test4(diagnostic_updater::DiagnosticStatusWrapper &status)
void summary(unsigned char lvl, const std::string s)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void add(const std::string &name, TaskFunction f)
void test3(diagnostic_updater::DiagnosticStatusWrapper &status)
void pretest(diagnostic_updater::DiagnosticStatusWrapper &status)
void summaryf(unsigned char lvl, const char *format,...)
void test2(diagnostic_updater::DiagnosticStatusWrapper &status)
Simple node with a self test that reports an error.
void checkTest()
Check if a self-test is pending. If so, start it and wait for it to complete.
Class to facilitate the creation of component self-tests.
void setID(std::string id)
Sets the ID of the part being tested.
void test1(diagnostic_updater::DiagnosticStatusWrapper &status)
void posttest(diagnostic_updater::DiagnosticStatusWrapper &status)
void add(const std::string &key, const T &val)
self_test::TestRunner self_test_
int main(int argc, char **argv)