[ROS基礎]日誌 & Log File === >[name=鍾鎧煜][time=2022_06_28] [TOC] ## ROS日誌 與cout輸出流不一樣的是,會在終端顯示的同時寫入日誌文件,並可以在rqt可視化工具中瀏覽。 - 5種Level,DEBUG > INFO > WARN > ERROR > FATAL ```cpp= if(ros::console::set_logger_level(ROSCONSOLE_DEFAULT_NAME, ros::console::levels::Debug)){ ros::console::notifyLoggerLevelsChanged();//默認 } while(ros::ok()){ ROS_DEBUG("DEBUG "); ROS_INFO("INFO"); ROS_WARN("WARN"); ROS_ERROR("ERROR"); ROS_FATAL("FATAL"); loop_rate.sleep(); } ```  ## Log File 在ROS中,有一個特殊的話題叫作/rosout,它承載著所有節點的所有日誌消息。/rosout消息的類型是rosgraph_msgs/Log  一般任務結束後日誌會輸出到隱藏目錄(ctrl + h) /home/your_computer/.ros/log 中,如果 log file 裡面的文件大小超過1GB,會出現 WARNING。  - 可以使用如下指令清除log檔 檢查大小 $ rosclean check 刪除log檔 $ rosclean purge - 輸出自訂 log 文件 會輸出到當前目錄中 SHELL=/bin/bash PS1="$" script -f name.log - rqt 可視化工具 $ rosrun rqt_console rqt_console  # Reference [ROS与C++入门教程-Logging(日志)](https://www.ncnynl.com/archives/201702/1299.html)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up