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

Revision history [back]

Here is a tiny little example adapted from the roscpp [publisher/subscriber](http://www.ros.org/wiki/ROS/Tutorials/WritingPublisherSubscriber(c%2B%2B) tutorial.

#include <ros/ros.h>
#include "roscopter/RC.h"

int main(int argc, char **argv)
{
    ros::init(argc, argv, "rc_sender");
    ros::NodeHandle n;
    ros::Publisher rc_pub = n.advertise<roscopter::RC>("send_rc", 1000);
    ros::Rate loop_rate(10);
    int count = 0;
    while (ros::ok())
    {
    roscopter::RC msg;
    rc_pub.publish(msg);
    ros::spinOnce();
    loop_rate.sleep();
    ++count;
    }
    return 0;
}

My manifest.xml (or package.xml in Groovy) declares the roscopter package as a dependency. Also, my CMakeLists.txt file is set to compile this file. Running the produced executable indeed publishes an empty roscopter/RC message at 10 Hz.