Robotics StackExchange | Archived questions

c++ advertizer: expected primary-expression before ‘>’ token

I have a script where there is a subscriber which is implemented like the following:

sub_setpoint_ = this->nh_->subscribe("controllerReference", 1,
    &CartesianImpedanceControllerROS<ROBOT, COMPENSATE_GRAVITY>::setpointCallback, this,
    ros::TransportHints().tcpNoDelay());

and I would like to also make a publisher inside it. What I tried was to write something rather similar to the above subscriber:

 pub_setpoint_status_   = this->nh_->advertise<std_msgs::String>("set_point_status", 1);

However, this gives me the error:

 error: expected primary-expression before ‘>’ token
       pub_setpoint_status_   = this->nh_->advertise<std_msgs::String>("set_point_status", 1);

which with my basic c++ experience is unclear what the problem might be. Does anyoone know what I should do?

msgs::String>("setpointstatus", 1);

Asked by azerila on 2020-08-01 18:35:12 UTC

Comments

Have you #included the std_msgs/String.h header in the compilation unit in which you're trying to use the type?

Asked by gvdhoorn on 2020-08-02 04:57:42 UTC

@gvdhoorn yea I have done so with #include <std_msgs/String.h> and since in the same script declaring std_msgs::String msg; compiles with no problem I assume the include works.

Asked by azerila on 2020-08-02 06:01:07 UTC

Did you change your cmakelist c++ compiler version? ( add_compile_options(-std=c++11) )

Asked by Teo Cardoso on 2020-08-03 15:42:41 UTC

Answers