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

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

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

mrrius gravatar image

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

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.

RoverMove.cpp

#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);
   ros::spin();
   return 0;
}

rover_move.h

#include "ros/ros.h"
#include"geometry_msgs/Twist.h"

#ifndef ROVER_MOVE_H
#define ROVER_MOVE_H


void goal_call_back(geometry_msgs::Twist goal);


#endif /* ROVER_MOVE_H */

RoverMoveLib.cpp

#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:

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

Comments

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 -0600 )edit

1 Answer

Sort by » oldest newest most voted
2

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

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");

to

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

Comments

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

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

Question Tools

1 follower

Stats

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

Seen: 1,142 times

Last updated: Nov 06 '19