ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Boost error: ‘f’ cannot be used as a function

asked 2019-11-05 20:48:56 -0500

mrrius gravatar image

updated 2019-11-05 20:49:55 -0500

I encountered a really strange error. I am writing a really simple code. Mostly still empty and just learning how to write node in C++. My code consist of 3 files.


#include "rover_move/rover_move.h"

int main(int argc, char** argv) {
   ros::init(argc, argv, "RoverMove");
   ros::NodeHandle n;
   ros::Subscriber goal_sub;
   ros::Publisher vel_pub;

   goal_sub = n.subscribe<geometry_msgs::Twist>("goal", 1, "goal_call_back");
   vel_pub = n.advertise<geometry_msgs::Twist>("cmd_vel", 1);
   return 0;


#include "ros/ros.h"

#ifndef ROVER_MOVE_H
#define ROVER_MOVE_H

void goal_call_back(geometry_msgs::Twist goal);

#endif /* ROVER_MOVE_H */


#include "rover_move/rover_move.h"

void goal_call_back(geometry_msgs::Twist goal){
// still empty 

I have input necessary config in CMake file and I got this error:


Can anyone help me why this happened? I just want to try a simple code. Publishing and subscribng to Twist type message.

edit retag flag offensive close merge delete


It would help if you edit your question and add the contents of your CMakeLists.txt file. Please copy and paste that file and any terminal output into code blocks, that makes it easier to read, search, and copy/paste.

Thomas D gravatar image Thomas D  ( 2019-11-06 01:05:59 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2019-11-06 01:07:27 -0500

Thomas D gravatar image

One problem is that when you declare your subscriber you are putting the callback function in double quotes. Try to change from

goal_sub = n.subscribe<geometry_msgs::Twist>("goal", 1, "goal_call_back");


goal_sub = n.subscribe<geometry_msgs::Twist>("goal", 1, goal_call_back);
edit flag offensive delete link more


this works! thanks. I made a mistake quoting the function name.

mrrius gravatar image mrrius  ( 2019-11-06 01:17:27 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-11-05 20:48:56 -0500

Seen: 974 times

Last updated: Nov 06 '19