【ROS笔记本】ROS使用节点句柄nh(“~“)和nh的区别:发布的话题不同

使用节点句柄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

猜你喜欢

转载自blog.csdn.net/weixin_51060040/article/details/123136628