Integrating ROS 2 APIs in the GTest framework
In the previous example, we learned how to run GTest using ROS 2 commands. However, in a real robotic application, that example may not be very practical. Let’s take our use of GTest a step further with a new example. In this example, we’ll test the output of a ROS 2 node that publishes to a ROS 2 topic. The purpose of the node is to convert an input string (received on a topic) to all lowercase letters. For instance, the string INpUt
would be converted to input
. To start, we need to create a package and the node we want to test. We’ll create the following source files:
to_lowercase.h
to store the definition of the ROS 2 node class and its variablesto_lowercase.cpp
to implement the functions to convert the letters from uppercase to lowercasemain.cpp
to instantiate and spin the ROS 2 node
We will separate the class and function definitions into different source files, allowing us to...