ROS_Kinetic_22 使用ROS的qt插件即ros_qtc_plugin实现Hi ROS!!!!

举报
zhangrelay 发表于 2021/07/15 06:59:39 2021/07/15
【摘要】 官网已经更新了教程说明,在此特别说明: https://github.com/ros-industrial/ros_qtc_plugin/wiki This wiki explains the procedure for installing the ROS Qt Creator Plug-in. Table of Contents 1.1 Installat...

官网已经更新了教程说明,在此特别说明:

https://github.com/ros-industrial/ros_qtc_plugin/wiki

This wiki explains the procedure for installing the ROS Qt Creator Plug-in.

Table of Contents

1.1 Installation Procedure for Ubuntu 14.04
1.2 Installation Procedure for Ubuntu 16.04
1.3 Installation Issues and Conflicts
1.4 Testing Plugin
1.5 Proceed to Next Step

1.1 Installation Procedure for Ubuntu 14.04


  
  1. sudo add-apt-repository ppa:beineri/opt-qt57-trusty
  2. sudo add-apt-repository ppa:levi-armstrong/ppa
  3. sudo apt-get update && sudo apt-get install qt57creator-plugin-ros

1.2 Installation Procedure for Ubuntu 16.04


  
  1. sudo add-apt-repository ppa:beineri/opt-qt57-xenial
  2. sudo add-apt-repository ppa:levi-armstrong/ppa
  3. sudo apt-get update && sudo apt-get install qt57creator-plugin-ros

1.3 Installation Issues and Conflicts

  • No known issues

1.4 Testing Plugin.

  1. Start Qt Creator

    • Option 1: Launch using the desktop icon.
    • Option 2: Launch from terminal. Before you can launch from the terminal perform one of the action below.
      • Add "source /opt/qt57/bin/qt57-env.sh" to the users .bashrc file.
      • Create a symbolic link file in you /usr/local/bin called qtcreator which points to /opt/qt57/bin/qtcreator-wrapper
  2. To verify that the plugin exist, goto File>New File or Project>Projects>Import Project>Import ROS Workspace. If the Import ROS Workspace is present then everything built correctly and is ready for development and testing.

 

Table of Contents

1.1 Setup
1.1.1 Download development packages
1.1.1.1 Installation Procedure for Ubuntu 14.04
1.1.1.2 Installation Procedure for Ubuntu 16.04
1.1.2 Configure system
1.1.3 Run ROS Qt Creator setup script.
1.1.4 Testing Plugin
1.1.5 Debug issues with Plugin

1.1 Setup

This section explains how to setup your system for development

1.1.1 Download development packages

1.1.1.1 Installation Procedure for Ubuntu 14.04


  
  1. sudo add-apt-repository ppa:beineri/opt-qt57-trusty
  2. sudo add-apt-repository ppa:levi-armstrong/ppa
  3. sudo apt-get update && sudo apt-get install qt57creator-plugin-ros libqtermwidget57-0-dev

1.1.1.2 Installation Procedure for Ubuntu 16.04


  
  1. sudo add-apt-repository ppa:beineri/opt-qt57-xenial
  2. sudo add-apt-repository ppa:levi-armstrong/ppa
  3. sudo apt-get update && sudo apt-get install qt57creator-plugin-ros libqtermwidget57-0-dev

1.1.2 Configure system to use the new version of Qt

After installation you need to tell qtchooser where to find this install. Replace the two lines in the file below with the location to the local version shown below. Make sure to change username and versionin the file path to match your system.

File:

sudo gedit /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf 

 

File content:


  
  1. /opt/qt57/bin
  2. /opt/qt57/lib

1.1.3 - Run ROS Qt Creator setup script.

  1. Clone your fork of the repository.
    $ git clone -b master https://github.com/<username>/ros_qtc_plugins.git
  2. Next in a terminal, navigate into the repository directory and execute the command below.
    $ bash setup.sh -d

    Note: Instruction 2 can can be repeated to get the latest updates for Qt Creator source. The developer must manually update there fork to get the latest version of ros_qtc_plugins.

1.1.4 Testing Plugin.

  1. Execute the command below or launch using the desktop launcher.
    $ qtcreator
  2. To verify that the plugin exist, goto File>New File or Project>Projects>Import Project>Import ROS Workspace. If the Import ROS Workspace is present then everything built correctly and is ready for development and testing.

1.1.5 - Debug issues with Plugin

  1. Next in a terminal, navigate to the repository ros_qtc_plugin and execute the command below.
    $ bash setup.sh -di
  2. Now launch qtcreator using gdb as shown below and after the plugin segfaults post the trace back in the active/new issue.

    
        
    1. $ gdb <local>/qt-creator-build/bin/qtcreator
    2. (gdb) run

    After error:

    (gdb) bt
       

 

 

 

参考链接:1. http://blog.csdn.net/u013453604/article/details/52186375

                    2. http://blog.csdn.net/zhangrelay/article/details/52068865

 

之前,帖子写得太过简略,这里学习和参考了张京林的博客

如果使用的是ubuntu 14.04和ROS(indigo),参考他的博客,教程非常详细。

 

这里测试的是ubuntu 16.04和ROS(kinetic)。但是过程和细节几乎一致。

开启终端,输入:

~$ qtcreator
 

Ctrl+N



分为项目与文件和类。

新建catkin工作空间,并在其中创建功能包,实现Hi ROS!!!!

1 新建工作空间

单击下图Choose...


Name:catkin_HiROS

Path:/home/xxx/catkin_HiROS

弹出对话框,点击Yes,初始化工作空间如下:


之后,点击Generate Project File,完成后点击下一步(N)


在这个选项卡中,可以配置版本控制系统等,如不需要,点击完成(F)


这样就建好了一个空的工作空间,下面新建功能包,添加节点等。


2 创建功能包

在src上单击右键,添加新文件...


点击Choose...

然后填入一些功能包的细节信息,如下:


点击下一步(N),然后点击完成(F)


到此,功能包创建完成。

3 添加一个节点

在HiROS下的src上单击右键,添加新文件...




4 调试编译

需要修改CMakeList.txt,在Build中,进行如下修改:


  
  1. ###########
  2. ## Build ##
  3. ###########
  4. ## Specify additional locations of header files
  5. ## Your package locations should be listed before other locations
  6. # include_directories(include)
  7. include_directories(
  8. ${catkin_INCLUDE_DIRS}
  9. )
  10. ## Declare a C++ library
  11. # add_library(HiROS
  12. # src/${PROJECT_NAME}/HiROS.cpp
  13. # )
  14. ## Add cmake target dependencies of the library
  15. ## as an example, code may need to be generated before libraries
  16. ## either from message generation or dynamic reconfigure
  17. # add_dependencies(HiROS ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
  18. ## Declare a C++ executable
  19. add_executable(HiROS_node src/HiROS.cpp)
  20. ## Add cmake target dependencies of the executable
  21. ## same as for the library above
  22. # add_dependencies(HiROS_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
  23. ## Specify libraries to link a library or executable target against
  24. target_link_libraries(HiROS_node
  25. ${catkin_LIBRARIES}
  26. )



  
  1. add_executable(HiROS_node src/HiROS.cpp)
  2. target_link_libraries(HiROS_node
  3. ${catkin_LIBRARIES}
  4. )


点击构建,进行编译。这里出现警告。功能包命名不规范,应当使用小写字母。


5 运行节点

点击右侧项目,配置桌面->运行:


点击运行,可以在底栏8 ROS Terminals,查看输入结果:



-End-




文章来源: zhangrelay.blog.csdn.net,作者:zhangrelay,版权归原作者所有,如需转载,请联系作者。

原文链接:zhangrelay.blog.csdn.net/article/details/52214411

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。