Creating a ROS Node
What and Why
In robotics , many undergrads,engineers and even researchers use ROS as a framework to communicate across different components present in their robot. And it does so through ROS Nodes. Usually training an deeplearning model is a horrendous task ,and deploying it into real world is even more. So to make life little simpler for people in the field of robotics , especially those who use ROS ,effort was made to build a node which would take an rosimage as input and output the detections present in it using some trained object detection model. Basically the end user need not worry about writing code to deploy their model, instead they could just use the raw weights directly.
Work done and Difficulties
First we need to subscribe to a rostopic which publishes images. Then using DetectionSuite’s Massinferencer we run out inferences on it. This is where first problem shook it’s hand. We cannot pass extra variables to callback functions which is triggered when we receive a rosimage, atleast not in a straight forward manner. This really took a while to figure out , as suggested by my mentor , I was required to use Boost libraries to get the task done. Second was to overload the callback function to take care of the type of image that it was trying to subscribe. Now this part was not so straight forward ,as we need to tell the subscriber as to which topic we are subscribing to , beforehand. And once we tell that, that particular message which we receive from the rostopic to which we subscribed to , gets fixed (the type) , so even before it reaches the callback function it throws an error saying , as it does not match with the type it subscribes to. So currently this node accepts messages of type rosimages.
You can run the node using the following command.
rosrun detection_suite test _topic:=<topic name> _configfile:=<path/to/configfile>