使用节点句柄nh("~")和nh的区别:发布的话题的命名空间不同
一.使用节点句柄nh("~")
ros::NodeHandle nh("~");
ros::Rate loop_rate(10); //correspding interp period
ros::Publisher joint_pub = nh.advertise<sensor_msgs::JointState>("test_joint_states", 1);
则发布的话题名字为
节点名字+话题名字
/replay_jnt_path_node/test_joint_states
二.使用节点句柄nh
ros::NodeHandle nh;
ros::Rate loop_rate(10); //correspding interp period
ros::Publisher joint_pub = nh.advertise<sensor_msgs::JointState>("test_joint_states", 1);
则发布的话题名字为:话题名字
/test_joint_states