Skip to content

Instantly share code, notes, and snippets.

@okalachev
Created February 19, 2019 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okalachev/9a4619de8e15e3235d24c864fed5fa3d to your computer and use it in GitHub Desktop.
Save okalachev/9a4619de8e15e3235d24c864fed5fa3d to your computer and use it in GitHub Desktop.
ROS nodelet template
#include <ros/ros.h>
#include <nodelet/nodelet.h>
#include <pluginlib/class_list_macros.h>
#include <geometry_msgs/PoseStamped.h>
class Example : public nodelet::Nodelet
{
public:
Example() {}
private:
ros::Subscriber example_sub;
ros::Publisher example_pub;
void onInit()
{
ros::NodeHandle& nh = getNodeHandle();
ros::NodeHandle& nh_priv = getPrivateNodeHandle();
double param;
nh_priv.param("param", param, 100);
example_sub = nh.subscribe("sub", 1, &Example::callback, this);
example_pub = nh_priv.advertise<geometry_msgs::PoseStamped>("pub", 1);
}
void callback(geometry_msgs::PoseStamped& msg)
{
example_pub.publish(msg);
}
};
PLUGINLIB_EXPORT_CLASS(Example, nodelet::Nodelet)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment