在之前的基础上创建yao_node.cpp
#include<ros/ros.h>
#include<std_msgs/String.h>
int main(int argc, char *argv[])
{
ros::init(argc,argv,"yao_node");
printf("过去生于未来\n");
ros::NodeHandle nh;
ros::Publisher pub=nh.advertise<std_msgs::String>("gie_gie_dai_wo",10);
ros::Rate loop_rate(10);
while (ros::ok())
{
printf("我要开始刷屏了\n");
std_msgs::String msg;
msg.data = "求上车++++";
pub.publish(msg);
loop_rate.sleep();
}
return 0;
}
add_executable(yao_node src/yao_node.cpp)
target_link_libraries(yao_node
${catkin_LIBRARIES}
)
roscore
rosrun ssr_pkg yao_node
rostopic list
rostopic echo /gie_gie_dai_wo(eg:查看话题内容)
echo -e "\u6C42\u4E0A\u8F66++++"
(因为是中文所以要转码,英文不用)