Created
May 4, 2018 11:17
-
-
Save jdumont0201/809655cf78c400251f3d5773a077e140 to your computer and use it in GitHub Desktop.
Minimal ROS topic publisher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ros/ros.h> | |
#include <std_msgs/Int32.h> | |
int main(int argc, char** argv) { | |
ros::init(argc, argv, "topic_publisher"); | |
ros::NodeHandle nh; | |
ros::Publisher pub = nh.advertise<std_msgs::Int32>("counter", 1000); | |
ros::Rate loop_rate(2); | |
std_msgs::Int32 count; | |
count.data = 0; | |
while (ros::ok()) | |
{ | |
pub.publish(count); | |
ros::spinOnce(); | |
loop_rate.sleep(); | |
++count.data; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment