Ask Your Question
0

Can't compile my C++ ros_nxt publisher

asked 2013-01-23 06:47:31 -0500

Saho gravatar image

I'm new in programming, so i'm trying to make my own publisher to the topic wich controls the motors of my NXT, so here is the code that i have written.I'm not sure if it is the correct thing that i need to control the motors, but i can't compile it.

#include <nxt_msgs/JointCommand.h>
#include <ros/ros.h>

           template<class M> ros::Publisher ros::NodeHandle::advertise(const     nxt_msgs::JointCommand, uint32_t, bool)

        int main(int argc, char **argv)

    {
        ros::init(argc, argv, "JointCommand");

        ros::NodeHandle n;
        ros::Publisher pub = n.advertise<nxt_msgs::>("JointCommand", 1);
        ros::Rate loop_rate(10);

        int test=1;
        nxt_msgs::JointCommand c;
        c = nxt_msgs::JointCommand();
        test = c.effort;

        pub.publish(c);

        ros::spinOnce();
        loop_rate.sleep();

        return 0;
    }

when i try to make my package it gives me the following error :

/ros_workspace/NXT/src/rc.cpp:6:1: error: expected initializer before ‘int’
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2013-01-23 11:59:12 -0500

mirzashah gravatar image

The error seems to be caused by the template before int main(). I'm not sure what you're trying to do with that line...it looks like a function prototype without a semicolon. The template also doesn't make sense. If the prototype was valid, you'd also want to add a semicolon at the end to terminate

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2013-01-23 06:47:31 -0500

Seen: 413 times

Last updated: Jan 23 '13