ROS与Arduino学习(六)Logging日志
生活随笔
收集整理的這篇文章主要介紹了
ROS与Arduino学习(六)Logging日志
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
ROS與Arduino學習(六)Logging日志
?
Tutorial Level:客戶端與服務器
Next Tutorial:小案例節點通信
???? 本節較為簡單告訴大家如何向系統發布日志信息。
Tips 1 日志信息發布
節點提供了五種日志消息,分別是debug、information、warn、error、fatal。可以分別用以下函數調用。其中參數為一個字符串
nh.logdebug(debug);nh.loginfo(info);nh.logwarn(warn);nh.logerror(error);nh.logfatal(fatal);?
Tips 2 案例程序
/** rosserial PubSub Example* Prints "hello world!" and toggles led*/#include <ros.h> #include <std_msgs/String.h> #include <std_msgs/Empty.h>ros::NodeHandle nh;std_msgs::String str_msg; ros::Publisher chatter("chatter", &str_msg);char hello[13] = "hello world!";char debug[]= "debug statements"; char info[] = "infos"; char warn[] = "warnings"; char error[] = "errors"; char fatal[] = "fatalities";void setup() {pinMode(13, OUTPUT);nh.initNode();nh.advertise(chatter); }void loop() {str_msg.data = hello;chatter.publish( &str_msg );nh.logdebug(debug);nh.loginfo(info);nh.logwarn(warn);nh.logerror(error);nh.logfatal(fatal);nh.spinOnce();delay(500); }?
Tips 3 測試程序
?
#新終端打開 $ roscore #新終端打開 $ rosrun rosserial_python serial_node.py _port:=/dev/ttyUSB0?
轉載于:https://www.cnblogs.com/flyingjun/p/8951162.html
總結
以上是生活随笔為你收集整理的ROS与Arduino学习(六)Logging日志的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: System.out.println(R
- 下一篇: 虚拟机上的Linux学习