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");
86 status.
summary(diagnostic_msgs::DiagnosticStatus::ERROR,
"ID Lookup failed");
96 status.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"We made it past the exception throwing statement.");
103 status.
add(
"some value", some_val);
104 status.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"We successfully changed the value.");
109 if (some_val == 42.0)
111 status.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"We observed the change in value");
115 status.
summaryf(diagnostic_msgs::DiagnosticStatus::ERROR,
"We failed to observe the change in value, it is currently %f.", some_val);
121 ROS_INFO(
"Doing cleanup stuff after we run our test.\n");
122 status.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"Posttest completed successfully.");
137 int main(
int argc,
char** argv)
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.
int main(int argc, char **argv)
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_