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
// Header file for ROS | |
#include "ros/ros.h" | |
// Header file for messages | |
#include "std_msgs/Float64.h" | |
int main(int argc, char **argv) | |
{ | |
// Initialize the node, name it NumberPublisher | |
ros::init(argc, argv, "NumberPublisher"); | |
// Create a node handler |
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> | |
void counterCallback(const std_msgs::Int32::ConstPtr& msg) | |
{ | |
ROS_INFO("%d", msg->data); | |
} | |
int main(int argc, char** argv) { |
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); |