ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

rosserial_mbed service build error: "no instance of constructor..."

asked 2020-09-23 08:40:01 -0600

Gualor gravatar image

Hi everyone, I am currently working on an application on the GAPuino development board, which is based on the rosserial_mbed library to enable messages/services exchange with the main node running on an Ubuntu 18.04 machine that uses ROS Melodic distro.

In the process of testing the functionalities of rosserial_mbed, I encountered an issue in the compiling of the following piece of code:

#include <mbed.h>
#include <ros.h>
#include <foo_pkg/foo_service.h>

bool fooCallback(foo_pkg::foo_service::Request& req, foo_pkg::foo_service::Response& res)
{
    // Do something
    return true;
}

ros::NodeHandle nh;
ros::ServiceServer<foo_pkg::foo_service::Request, 
                   foo_pkg::foo_service::Response> 
                   service("foo_service", &fooCallback);

int main(void)
{
    nh.initNode();
    nh.advertiseService(service);
    while(1)
    {
        nh.spinOnce();
        wait_ms(1000);
    }
    return 0;
}

Which during the build, got me the following error message:

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/riscv_gap/gapuino.html
PLATFORM: RISC-V GAP (1.0.4) > GAPuino GAP8
HARDWARE: GAP8 250MHz, 8MB RAM, 64MB Flash
DEBUG: Current (ftdi) On-board (ftdi)
PACKAGES: 
 - framework-gap_sdk 2.0.0 
 - tool-pulp_tools 0.1.181108 
 - toolchain-riscv-pulp 1.70101.181017 (7.1.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 1 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ros_lib>
Building in release mode
Compiling .pio/build/gapuino/src/main.o
src/main.cpp:99:31: error: invalid conversion from 'bool (*)(foo_pkg::foo_service::Request&, foo_pkg::foo_service::Response&) {aka bool (*)(foo_pkg::foo_serviceRequest&, foo_pkg::foo_serviceResponse&)}' to 'ros::ServiceServer<foo_pkg::foo_serviceRequest, foo_pkg::foo_serviceResponse>::CallbackT {aka void (*)(const foo_pkg::foo_serviceRequest&, foo_pkg::foo_serviceResponse&)}' [-fpermissive]
    service("foo_service", &fooCallback);
                           ^~~~~~~~~~~~
In file included from /home/gualor/.platformio/lib/ros_lib/ros/node_handle.h:61:0,
             from /home/gualor/.platformio/lib/ros_lib/ros.h:38,
             from src/main.cpp:87:
/home/gualor/.platformio/lib/ros_lib/ros/service_server.h:94:3: note:   initializing argument 2 of 'ros::ServiceServer<MReq, MRes, void>::ServiceServer(const char*, ros::ServiceServer<MReq, MRes, void>::CallbackT) [with MReq = foo_pkg::foo_serviceRequest; MRes = foo_pkg::foo_serviceResponse; ros::ServiceServer<MReq, MRes, void>::CallbackT = void (*)(const foo_pkg::foo_serviceRequest&, foo_pkg::foo_serviceResponse&)]'
ServiceServer(const char* topic_name, CallbackT cb) : 
^~~~~~~~~~~~~
*** [.pio/build/gapuino/src/main.o] Error 1

Also the intellisense of Visual Studio Code, that I'm using as IDE, reported this 2 errors as well:

1)

no instance of constructor "ros::ServiceServer<MReq, MRes, void>::ServiceServer [with MReq=foo_pkg::foo_service::Request, MRes=foo_pkg::foo_service::Response]" matches the argument list -- argument types are: (const char [12], bool (*)(foo_pkg::foo_service::Request &req, foo_pkg::foo_service::Response &res))

2)

invalid conversion from 'bool (*)(foo_pkg::foo_service::Request&, foo_pkg::foo_service::Response&) {aka bool (*)(foo_pkg::foo_serviceRequest&, foo_pkg::foo_serviceResponse&)}' to 'ros::ServiceServer<foo_pkg::foo_serviceRequest, foo_pkg::foo_serviceResponse>::CallbackT {aka void (*)(const foo_pkg::foo_serviceRequest&, foo_pkg::foo_serviceResponse&)}' [-fpermissive]

My current setup is the following:

  • OS: Ubuntu 18.04
  • IDE: Visual Studio Code running PlatformIO extension
  • Board: GAPuino GAP8
  • Platform: RISC-V GAP
  • Framework: Mbed

Thank you in advance, any suggestion is welcomed.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-01-29 01:02:37 -0600

FAL6863 gravatar image

Hi, Gualor.
Change

bool fooCallback()

to

void fooCallback()

and delete

return true

may resolve your problem.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-09-23 08:40:01 -0600

Seen: 201 times

Last updated: Sep 23 '20