Skip to content

Instantly share code, notes, and snippets.

@jdumont0201
Last active May 4, 2018 11:38
Show Gist options
  • Save jdumont0201/4461cbbb3ce1fe0babcc910dd3d5712e to your computer and use it in GitHub Desktop.
Save jdumont0201/4461cbbb3ce1fe0babcc910dd3d5712e to your computer and use it in GitHub Desktop.
Minimal ROS node with keep-alive
#include <ros/ros.h>
int main(int argc, char** argv) {
ros::init(argc, argv, "ObiWan");
ros::NodeHandle nh;
ros::Rate loop_rate(2); // We create a Rate object of 2Hz
while (ros::ok()) { // Endless loop until Ctrl + C
ROS_INFO("Hello, World!");
ros::spinOnce();
loop_rate.sleep(); // We sleep the needed time to maintain the Rate fixed above
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment