zoukankan      html  css  js  c++  java
  • 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
    
  • 相关阅读:
    动手动脑感想
    原码反码补码
    java测试感想
    报告
    假期报告
    假期报告
    java学习进度
    《大道至简》读后感
    2020/1/31 PHP代码审计之目录穿越漏洞
    [极客大挑战 2019]BabySQL
  • 原文地址:https://www.cnblogs.com/flyingjun/p/8951162.html
Copyright © 2011-2022 走看看