ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
The exact answer of my question is
#include "ros/ros.h"
#include "geometry_msgs/Twist.h"
ros::Publisher vel_pub;
void negotiatorCallback(const geometry_msgs::Twist::ConstPtr& msg)
{
vel_pub.publish(msg);
}
int main(int argc, char **argv)
{
flag = 0;
ros::init(argc, argv, "negotiator");
ros::NodeHandle p;
vel_pub = p.advertise<geometry_msgs::Twist>("cmd_vel",1000);
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe<geometry_msgs::Twist>("tele_cmd_vel", 0, negotiatorCallback);
ros::NodeHandle vel_sub;
ros::Subscriber tele_cmd_vel_sub = vel_sub.subscribe<geometry_msgs::Twist>("move_base_cmd_vel", 1000, negotiatorCallback);
ros::spin();
return 0;
}