1. 程式人生 > >ROS實踐(5)-除錯相關

ROS實踐(5)-除錯相關

一 編譯程式

[email protected]:~/dev/rosbook# cp -r /home/yangkai04/Documents/Learning\ ROS\ for\ Robotics\ Programming\ 1448OS_Code/1448OS_03_code/chapter3_tutorials .
[email protected]:~/dev/rosbook# mv chapter3_tutorials chapter3_tutorials.bak
[email protected]:~/dev/rosbook# roscreate-pkg chapter3_tutorials std_msgs rospy roscpp

Created package directory /root/dev/rosbook/chapter3_tutorials
Created include directory /root/dev/rosbook/chapter3_tutorials/include/chapter3_tutorials
Created cpp source directory /root/dev/rosbook/chapter3_tutorials/src
Created package file /root/dev/rosbook/chapter3_tutorials/Makefile
Created package file /root/dev/rosbook/chapter3_tutorials/manifest.xml
Created package file /root/dev/rosbook/chapter3_tutorials/CMakeLists.txt
Created package file /root/dev/rosbook/chapter3_tutorials/mainpage.dox

Please edit chapter3_tutorials/manifest.xml and mainpage.dox to finish creating your package
[email protected]
:~/dev/rosbook# ls
chapter2_tutorials  chapter3_tutorials  chapter3_tutorials.bak
[email protected]:~/dev/rosbook# ls chapter3_tutorials2
CMakeLists.txt  include  mainpage.dox  Makefile  manifest.xml  src
[email protected]:~/dev/rosbook# cp -r chapter3_tutorials.bak/* chapter3_tutorials/
[email protected]
:~/dev/rosbook# cd chapter3_tutorials
[email protected]:~/dev/rosbook/chapter3_tutorials# ls
bag             config   launch        Makefile      output  srv
CMakeLists.txt  include  mainpage.dox  manifest.xml  src
[email protected]:~/dev/rosbook/chapter3_tutorials# rospack depends chapter3_tutorials
[rospack] Error: package 'chapter3_tutorials' depends on non-existent package 'opencv2' and rosdep claims that it is not a system dependency. Check the ROS_PACKAGE_PATH or try calling 'rosdep update'

解決:

簡單的說,就是indigo版本以後,opencv的包,就不叫opencv2了,改成cv_bridge即可。


再次執行rosmake

[email protected]:~/dev/rosbook/chapter3_tutorials# rosmake
[rospack] Error: package 'chapter3_tutorials' depends on non-existent package 'pcl' and rosdep claims that it is not a system dependency. Check the ROS_PACKAGE_PATH or try calling 'rosdep update'

解決:
當前不叫pcl了,可以用命令檢視:
[email protected]:~/dev/rosbook/chapter3_tutorials# rospack list | grep pcl
pcl_conversions /opt/ros/indigo/share/pcl_conversions
pcl_msgs /opt/ros/indigo/share/pcl_msgs
pcl_ros /opt/ros/indigo/share/pcl_ros

因此,把manifest.xml中:
  <depend package="pcl"/>
改為:
  <depend package="pcl_conversions"/>
  <depend package="pcl_msgs"/>
即可。

最後,再修改下example1.cpp,將以下幾行註釋掉:

  //ROSCONSOLE_AUTOINIT;
  //log4cxx::LoggerPtr my_logger =
  //  log4cxx::Logger::getLogger( ROSCONSOLE_DEFAULT_NAME );
  //my_logger->setLevel(
  //  ros::console::g_level_lookup[ros::console::levels::Debug]
  //);
重新編譯,即可成功 [email protected]:~/dev/rosbook/chapter3_tutorials# ls
bag  bin  build  CMakeLists.txt  config  include  launch  mainpage.dox  Makefile  manifest.xml  output  src  srv  srv_gen
[email protected]:~/dev/rosbook/chapter3_tutorials# rosmake
[ rosmake ] Results:                                                                                                                     
[ rosmake ] Built 65 packages with 0 failures.                                                                                           
[ rosmake ] Summary output to directory                                                                                                  
[ rosmake ] /root/.ros/rosmake/rosmake_output-20161110-145543  

二 除錯-啟動方法一

terminal1 啟動主節點

[email protected]:/home/yangkai04# roscore
... logging to /root/.ros/log/3e7bc9d8-a714-11e6-bcd2-f48e38af57c0/roslaunch-yangkai04-Inspiron-3650-7572.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://yangkai04-Inspiron-3650:46094/
ros_comm version 1.11.20

terminal2 啟動其他節點

[email protected]:/home/yangkai04# roscd chapter3_tutorials

[email protected]:~/dev/rosbook/chapter3_tutorials# gdb bin/example1
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from bin/example1...done.
(gdb) r
Starting program: /root/dev/rosbook/chapter3_tutorials/bin/example1
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff170d700 (LWP 3299)]
[New Thread 0x7ffff0f0c700 (LWP 3300)]
[New Thread 0x7fffebfff700 (LWP 3301)]
[New Thread 0x7fffeb7fe700 (LWP 3306)]
[Thread 0x7fffeb7fe700 (LWP 3306) exited]
[Thread 0x7ffff170d700 (LWP 3299) exited]
[Thread 0x7ffff0f0c700 (LWP 3300) exited]
[Thread 0x7ffff7fbe7c0 (LWP 3294) exited]
[Inferior 1 (process 3294) exited normally]

三 除錯-啟動方法二

建立launch檔案到chapter3_tutorials/launch/example1_gdb.launch,檔案內容如下:

<?xml version="1.0" encoding="UTF-8"?>

<launch>
  <!-- Logger config -->
  <env name="ROSCONSOLE_CONFIG_FILE"
       value="$(find chapter3_tutorials)/config/chapter3_tutorials.config"/>

  <!-- Example 1 -->
  <node pkg="chapter3_tutorials" type="example1" name="example1"
        output="screen" launch-prefix="xterm -e gdb --args"/>
</launch>

啟動主節點(rescore),以後都忽略該命令的輸出

啟動除錯節點

roslaunch chapter3_tutorials example1_gdb.launch

執行結果


四 除錯-valgrind

安裝valgrind:

apt-get install valgrind

[email protected]:/home/yangkai04# val
valgrind            valgrind-di-server  validlocale
valgrind.bin        valgrind-listener   
[email protected]:/home/yangkai04# valgrind

編輯launch檔案:

[email protected]:/home/yangkai04# roscd chapter3_tutorials
[email protected]:~/dev/rosbook/chapter3_tutorials# vim launch/example1_valgrind.launch
<?xml version="1.0" encoding="UTF-8"?>

<launch>
  <!-- Logger config -->
  <env name="ROSCONSOLE_CONFIG_FILE"
       value="$(find chapter3_tutorials)/config/chapter3_tutorials.config"/>

  <!-- Example 1 -->
  <node pkg="chapter3_tutorials" type="example1" name="example1"
        output="screen" launch-prefix="valgrind"/>
</launch>

啟動,下表中,紫色字型部分是valgrind輸出資訊。

[email protected]:~/dev/rosbook/chapter3_tutorials# roslaunch chapter3_tutorials example1_valgrind.launch
... logging to /root/.ros/log/61204ce8-a71e-11e6-bcd2-f48e38af57c0/roslaunch-yangkai04-Inspiron-3650-5695.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://yangkai04-Inspiron-3650:43913/

SUMMARY
========

PARAMETERS
 * /rosdistro: indigo
 * /rosversion: 1.11.20

NODES
  /
    example1 (chapter3_tutorials/example1)

auto-starting new master
process[master]: started with pid [5707]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 61204ce8-a71e-11e6-bcd2-f48e38af57c0
process[rosout-1]: started with pid [5720]
started core service [/rosout]
process[example1-2]: started with pid [5724]
==5724== Memcheck, a memory error detector
==5724== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==5724== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==5724== Command: /root/dev/rosbook/chapter3_tutorials/bin/example1 __name:=example1 __log:=/root/.ros/log/61204ce8-a71e-11e6-bcd2-f48e38af57c0/example1-2.log
==5724==
[DEBUG] [1478765961.873507730]: This is a simple DEBUG message!
[DEBUG] [1478765961.907039003]: This is a DEBUG message with an argument: 3.140000
[DEBUG] [1478765961.916783000]: This is DEBUG stream message with an argument: 3.14

==5724==
==5724== HEAP SUMMARY:
==5724==     in use at exit: 3,724 bytes in 48 blocks
==5724==   total heap usage: 2,537 allocs, 2,489 frees, 188,408 bytes allocated
==5724==
==5724== LEAK SUMMARY:
==5724==    definitely lost: 0 bytes in 0 blocks
==5724==    indirectly lost: 0 bytes in 0 blocks
==5724==      possibly lost: 716 bytes in 13 blocks
==5724==    still reachable: 3,008 bytes in 35 blocks
==5724==         suppressed: 0 bytes in 0 blocks
==5724== Rerun with --leak-check=full to see details of leaked memory
==5724==
==5724== For counts of detected and suppressed errors, rerun with: -v
==5724== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

[example1-2] process has finished cleanly
log file: /root/.ros/log/61204ce8-a71e-11e6-bcd2-f48e38af57c0/example1-2*.log

^C[rosout-1] killing on exit
[master] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete
done

相關推薦

ROS實踐5-除錯相關

一 編譯程式 [email protected]:~/dev/rosbook# cp -r /home/yangkai04/Documents/Learning\ ROS\ for\ Robotics\ Programming\ 1448OS_Code/1448O

python爬微信公眾號前10篇歷史文章5-JSON相關內容小結

字符串轉換 但是 字符串 cname 例子 row none literal nco json — JSON encoder and decoder JSON: JavaScript object notation,是一種輕量級的數據交換格式。JSON 是 JS 對

框架綜合實踐5-loginView測試用例封裝

測試用例封裝 在業務資料夾businessView資料夾下已經封裝好了登入模組的測試指令碼,現在要將登入模組進一步封裝成測試用例。 指令碼概要: Myunit.py:定義了測試用例執行的初始化和結束,類名StarEnd LoginView.py:定義登入的整個業務操作模組

react專案實踐——5路由配置

1. 新建檔案routes.js,分別定義頁面的路由資訊和其他資訊 const Routes = { 100: { title: "home", pageName: "home", path: "/home" },   101: {    

Spring+SpringMVC+MyBatis入門實踐5

註解方式AOP 註解配置切面 @Aspect 註解表示這是一個切面 @Component 表示這是一個bean,由Spring進行管理 @Around(value = “execution(* com.happycoder.service.ProductServ

TensorFlow實踐5——多元線性迴歸模型

(一)前 言 一元線性迴歸是一個主要影響因素作為自變數來解釋因變數的變化,但在現實問題中,因變數的變化往往受到多個重要因素的影響,這時就需要兩個或兩個以上的影響因素作為自變數來解釋因變數的變化,這便是多元迴歸,而當多個自變數與因變數之間是線性關係時,所進

JPA學習筆記5——EntityManager相關

                     Persistence在之前的JPA學習筆記(2)——建立JPA專案,有使用到Persistence來建立EntityManagerFactory例項String persistenceUnitName = "jpa"; EntityManagerFactory fa

CAS單點登入5相關參考資料

目錄 目錄 github地址: 較完整的教程CSDN 學習總結 第三方登入 其他 github地址: https://github.com/apereo/cas https://g

實踐5倒排索引

背景         搜尋引擎通常都會建立關鍵字的倒排索引,由關鍵字為index,後面跟著包含該關鍵字的網頁,本次使用模擬資料,簡要嘗試一下,建立倒排索引的過程。資料:第一個元素為書名字,後面以空格分割,為書的關鍵字。spark版本:<dependency>

敏捷開發實踐5-有些工具不得不用

做敏捷開發,貴在敏捷,如何敏捷?我們需要一系列成熟的工具去幫助我們敏捷。 這篇文件不寫技術,就是純粹地說工具,介紹我們實施scrum過程中,起到關鍵作用的工具。 1、Jira或物理看板 Jira配合JIRA Agile外掛,即可實施敏捷開發,核心就是提供了一個電子

流式大資料計算實踐5----HBase使用

一、前言 1、上文中我們搭建好了一套HBase叢集環境,這一文我們學習一下HBase的基本操作和客戶端API的使用 二、shell操作 先通過命令進入HBase的命令列操作 /work/soft/hbase-1.2.2/bin/hbase shell 1、建表 create 'test

5python相關函式

一、前言 因個人習慣,在閱讀和學習文字資料時,習慣摘寫筆記,因此在這裡留下自己的學習記錄。筆記的內容偏摘抄為主,並非自己的原創內容。 內容基於:《簡明 Python 教程》Swaroop, C. H. 著沈潔元  譯 二、函式 (1)定義 函式是重用的程式段,可以為

Python學習筆記5--類相關語法

1.呼叫父類方法 super(SubClassName, self).__init__(args) super(SubClassName, self).method(args) 2.私有元素 新增'_'字首 3.python描述符 描述符用來自定義在引用一個物件上的特性

ROS實踐N-常見錯誤

一 找不到opencv 錯誤: [email protected]:~/dev/rosbook/chapter3_tutorials# rospack depends chapter3_tutorials [rospack] Error: package 'cha

吳裕雄 python深度學習與實踐5

sci import array pat size ipy csv ima sta import numpy as np data = np.mat([[1,200,105,3,False], [2,165,80,2,False],

知識圖譜學習與實踐5——Protégé使用入門

1 Protégé簡介 Protégé是一個本體建模工具軟體,由斯坦福大學基於java語言開發的,屬於開放原始碼軟體。軟體主要用於語義網中本體的構建和基於本體的知識應用,是本體構建的核心開發工具,最新版本為5.5.0(截至2019年7月)。 Prot

Android自己定義組件系列【5】——進階實踐2

col fonts tle 適配 pack tom ica void log 上一篇《Android自己定義組件系列【5】——進階實踐(1)》中對任老師的《可下拉的PinnedHeaderExpandableListView的實現》前一部分進行了實現,這一篇我們來看看Ex

vue-cli腳手架npm相關文件說明5vue-loader.conf.js

傳送門 env loader tar 文章 .html 系列 uil class 系列文章傳送門: 1、build/webpack.base.conf.js 2、build/webpack.prod.conf.js 3、build/webpack.dev.conf

Java並發編程實踐讀書筆記5 線程池的使用

設計 java並發編程 指定 數據交換 什麽 讀書 body 發展 ima Executor與Task的耦合性 1,除非線程池很非常大,否則一個Task不要依賴同一個線程服務中的另外一個Task,因為這樣容易造成死鎖; 2,線程的執行是並行的,所以在設計Task的時候要考慮

ROS系統玩轉自主移動機器人5-- ROS系統建模

關節 evo 編譯 val mpi ans ros 三維 mil 註:本篇博文全部源碼下載地址為:Git Repo傳送門。 1. 下載到本地後解壓到當前文件夾然後運行:catkin_make 編譯。 2. 源碼是在 Ubuntu14.04 + Indigo 環境下編寫。