Help on Reusing C++ functions

Hi @albertoezquerro

Is it possible to get more C++ help regarding reusing functions. I have tried reusing my subscriber in my action server, but so far have been unsuccessful. Should I make a new topic or post more info here about my problem?

Hi @albertoezquerro and @bayodesegun.

Apologies for the delay, I only just realised the new thread has been created, thanks for that.

Here is my issue.

I am doing the final project for C++. I have made a odom subscriber and a server so far as suggested. So for I have transfered over my odom subscriber. I assume, what you are meant to do in order to use the odom subscriber in the action server is to create a get method in the odom subscriber and call it in the server. So this is what I have tried.:

This is my odom subscriber:

As you can see I have the class and the getOdomData get method, which returns the Odometry which is provided by the callback.

Next I didn’t really know how to get that method in the server cpp file. So I assume you have to create an object. But to do that you need to #include the file I assume? And in order to do that you need a .h file. I have never made a header file before so I am unsure on if that is right. So far all our .h files have been compiled automatically for our msg files etc.

So I made this header file here:

As you can see, I have made the header file. Though I think it is incorrect as it is flagging errors. I am still unsure how to use this in order to get the getOdomData() method in the record_odom_action_server.cpp file. Can I get some help on this?

Many thanks


Hi All,

Apologies but did anyone get a chance to have a look at these?

Best wishes,