Subcriber cb not called when running Service server

I am trying to do the ROSJECT project part II (find the wall) of Ros2 Basics for C++ in 5 days.
The goal is to write a Service server for FindWall which responds to a service call.
My service callback handler sees the incoming request. I create a class FindWall which registers callbacks for /odom and /scan but they are never called for some reason.

My program flow is roughly as follows
class FindWallClass {
Register callbacks for /odom and /scan
void odom_callback(…)
void scan_callback(…)

FindWall findWallClass(g_node) ;

while (rclcpp::ok() && !findWallC.foundWall()) { loop_rate.sleep(); }

response->wallfound = true;
g_node->create_service("/find_wall_service", handle_service);

Hi, welcome to the community!

Could you please format your code correctly as you have it in your files? It’s really difficult to spot where things are going wrong with what you shared. Also, screenshots of any error messages you get from running your server are always helpful

Thanks for the reply.
What i figured was that when the Service callback is executed on a loop, the Subscription callbacks are never called/executed.
So I need to run the different callbacks in different threads. We don’t have such an example in the class notes.
Is there any example which shows how I can run the 3 callbacks - 2 Subscription callbacks for Odometry and LaserScan, 1 Service callback - in concurrent threads?

There is a simple example here, but doesnt seem to work in my ros2 environment


After making a few changes for ros2 foxy apis, the thread example quoted above helped.