Skip to content

Instantly share code, notes, and snippets.

@TheProjectsGuy
TheProjectsGuy / NumberPublisher.cpp
Created December 9, 2018 13:30
Simple Publisher made using C++ in ROS
// 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
#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) {
@jdumont0201
jdumont0201 / minimal_topic_publisher.cpp
Created May 4, 2018 11:17
Minimal ROS topic publisher
#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&lt;std_msgs::Int32&gt;("counter", 1000);
ros::Rate loop_rate(2);