33 #include "diagnostic_msgs/SelfTest.h" 77 ROS_ERROR(
"Value testing test2 was not found when trying to remove it.");
87 ROS_INFO(
"Doing preparation stuff before we run our test.\n");
88 status.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"Pretest completed successfully.");
102 bool lookup_successful =
true;
104 if (lookup_successful)
106 status.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"ID Lookup successful");
114 self_test_.
setID(ID);
117 status.
summary(diagnostic_msgs::DiagnosticStatus::ERROR,
"ID Lookup failed");
133 throw std::runtime_error(
"we did something that threw an exception");
136 status.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"We made it past the exception throwing statement.");
145 status.
add(
"some value", some_val);
146 status.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"We successfully changed the value.");
151 if (some_val == 42.0)
153 status.
summary(diagnostic_msgs::DiagnosticStatus::OK,
"We observed the change in value");
157 status.
summaryf(diagnostic_msgs::DiagnosticStatus::ERROR,
"We failed to observe the change in value, it is currently %f.", some_val);
163 ROS_INFO(
"Doing cleanup stuff after we run our test.\n");
164 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.
int main(int argc, char **argv)
bool removeByName(const std::string name)
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_