service not visible when launched inside class.
I'm attempting to implement a service in which the callback is a member function of a class (with reference to the tutorial)
My code, as below, builds and runs without error, outputting the expected "service launched!". Without using static
in the callback signature I get error: invalid use of non-static member function pointsCallback);
But when I run rosservice list
"test_service" or "X/test_service" isn't present. Why isn't my service visible?
#include <stdio.h>
#include <string>
#include <ros/ros.h>
#include "image_transform/TransformPoints.h"
class ImageTransform {
public:
ImageTransform() {
ros::NodeHandle private_nh("~");
ros::ServiceServer service = private_nh.advertiseService("test_service",
pointsCallback);
std::cout << "service launched!" << std::endl;
}
static bool pointsCallback(image_transform::TransformPoints::Request &req,
image_transform::TransformPoints::Response &res) {
std::cout << "service called" << std::endl;
return true;
}
};
int main(int argc, char **argv) {
// ROS NODE INIT
ros::init(argc, argv, "image_tranform");
ImageTransform image_transform;
ros::spin();
return 0;
}