I would like to emulate "design by contract" on the ROS node level by using diagnostics/self_test. To check a ROS nodes preconditions probably pretest()
(self_test example) could be used. The ROS nodes postconditions could be checked with posttest()
(self_test example). Could I trigger self_test test function execution when topics are published somehow?
Originally posted by thinwybk on ROS Answers with karma: 468 on 2017-10-02
Post score: 0
Original comments
Comment by gvdhoorn on 2017-10-02:
I guess this will depend on what it is you want to test / what is in your contract.
Comment by thinwybk on 2017-10-04:
The list of possible preconditions, postconditions and invariants which could be checked is long. The question is how checks could be executed in general. pretest() should work before ROS node startup (e.g. check if dependent on nodes are already running)...
Comment by thinwybk on 2017-10-04:
... invariant checking could be done whenever a node received a topic message or a service request which could potentially change the node into an invalid state. The question is if it would be possible with self_test to use kind of callback function mechanism which would allow to execute checks then
Comment by gvdhoorn on 2017-10-04:
I don't think that self_test
was intended to be used that way (it's more a "runtime testing" tool for diagnostic purposes), but perhaps it could be repurposed.
Comment by thinwybk on 2017-10-04:
I know. I am just thinking about if self_test could be used to support design by contract, built-in-selftesting, etc.