Tetrapod Project
rx_node.cpp
Go to the documentation of this file.
1 #include "ros/ros.h"
2 #include "sensor_msgs/JointState.h"
3 
4 class SubAndPub
5 {
6  public:
8  {
9  pub = nh.advertise<sensor_msgs::JointState>("/motor/states", 1);
10 
11  sub = nh.subscribe("/motor/commands", 1, &SubAndPub::callback, this);
12  }
13 
14  void callback(const sensor_msgs::JointState &_msg)
15  {
16  pub.publish(_msg);
17  }
18 
19  private:
20  ros::NodeHandle nh;
21  ros::Publisher pub;
22  ros::Subscriber sub;
23 };
24 
25 int main(int argc, char **argv)
26 {
27  ros::init(argc, argv, "slave_node");
28 
29  SubAndPub slave;
30 
31  ros::Rate loop_rate(100000);
32 
33  while(ros::ok())
34  {
35  loop_rate.sleep();
36  ros::spinOnce();
37  }
38 }
SubAndPub()
Definition: rx_node.cpp:7
ros::Subscriber sub
Definition: rx_node.cpp:22
void callback(const sensor_msgs::JointState &_msg)
Definition: rx_node.cpp:14
ros::Publisher pub
Definition: rx_node.cpp:21
ros::NodeHandle nh
Definition: rx_node.cpp:20
int main(int argc, char **argv)
Definition: rx_node.cpp:25