zoukankan      html  css  js  c++  java
  • MoveIt 仿真 Gazebe 教程学习(五)

    MoveIt 仿真 Gazebe 教程学习(五)

     

    【古月居】

    ROS探索总结(五)——创建简单的机器人模型smartcar,网址如下:

    https://www.guyuehome.com/243

    还有相关的一系列文章都可以看看。

    前提:

    源码地址:https://github.com/huchunxu/ros_exploring 需要把里面的 ROS2 文件夹删除,它不能放在 ROS1 环境中。把 ros_exploring 放在home/wei/moveit_wei/src 里面。

    catkin_make文件ros_exploring的流程:

     1 mkdir -p ~/moveit_wei2/src
     2  3 cd ~/moveit_wei2/src/
     4  5 git clone http://github.com/plasmodic/ecto.git
     6  7 sudo apt-get install libboost-python-dev libboost-filesystem-dev libboost-system-dev 
     8         libboost-thread-dev python-setuptools python-gobject python-gtk2 graphviz doxygen 
     9         python-sphinx
    10 11 12 git clone https://github.com/ros-interactive-manipulation/manipulation_msgs.git
    13 14 git clone https://github.com/ros-interactive-manipulation/household_objects_database_msgs.git
    15 16 cd ../
    17 18 catkin_make

    问题1:

     1 -- Could NOT find ecto (missing: ecto_DIR)
     2 -- Could not find the required component 'ecto'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
     3 CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
     4   Could not find a package configuration file provided by "ecto" with any of
     5   the following names:
     6  7     ectoConfig.cmake
     8     ecto-config.cmake
     9 10   Add the installation prefix of "ecto" to CMAKE_PREFIX_PATH or set
    11   "ecto_DIR" to a directory containing one of the above files.  If "ecto"
    12   provides a separate development package or SDK, be sure it has been
    13   installed.
    14 Call Stack (most recent call first):
    15   ros_exploring/robot_perception/ork_tutorials/CMakeLists.txt:4 (find_package)
    16 17 18 -- Configuring incomplete, errors occurred!
    19 See also "/home/wei/moveit_wei2/build/CMakeFiles/CMakeOutput.log".
    20 See also "/home/wei/moveit_wei2/build/CMakeFiles/CMakeError.log".
    21 Invoking "cmake" failed
    22

    解决:

    1 cd ~/moveit_wei2/src
    2 3 git clone http://github.com/plasmodic/ecto.git
    4 5 sudo apt-get install libboost-python-dev libboost-filesystem-dev libboost-system-dev 
    6         libboost-thread-dev python-setuptools python-gobject python-gtk2 graphviz doxygen 
    7         python-sphinx

    问题2:

     1 CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
     2   Could not find a package configuration file provided by "move_base_msgs"
     3   with any of the following names:
     4  5     move_base_msgsConfig.cmake
     6     move_base_msgs-config.cmake
     7  8   Add the installation prefix of "move_base_msgs" to CMAKE_PREFIX_PATH or set
     9   "move_base_msgs_DIR" to a directory containing one of the above files.  If
    10   "move_base_msgs" provides a separate development package or SDK, be sure it
    11   has been installed.
    12 Call Stack (most recent call first):
    13   ros_exploring/robot_mrobot/mrobot_navigation/CMakeLists.txt:7 (find_package)
    14 15 16 -- Configuring incomplete, errors occurred!
    17 See also "/home/wei/moveit_wei2/build/CMakeFiles/CMakeOutput.log".
    18 See also "/home/wei/moveit_wei2/build/CMakeFiles/CMakeError.log".
    19 Invoking "cmake" failed
    20

    解决:

    1 sudo apt-get install ros-melodic-move-base-msgs

    问题3:

    1 fatal error: alsa/asoundlib.h: 没有那个文件或目录

    解决:

    1 sudo apt-get install libasound2-dev

    问题4:

    1 fatal error: boost/tr1/unordered_map.hpp: 没有那个文件或目录
    2  #include <boost/tr1/unordered_map.hpp>

    解决:

    1 1,进入到ecto的目录下使用如下命令找到这两个文件
    2 $ grep -r 'tr1'
    3 ./src/lib/util.cpp:#include <boost/tr1/unordered_map.hpp>
    4 ./src/lib/plasm/impl.hpp:#include <boost/tr1/unordered_map.hpp>
    5 
    6 
    7 把tr1删除,同时把代码里的std::tr1::unordered_map字段改成boost::unordered_map即可。


    grep 命令,用于查找文件里符合条件的字符串。

    vim 编辑文件。

    i 表示进入插入模式。

    ESC 表示进入普通模式。

    :wq 表示保存并退出。

    参考博客:https://blog.csdn.net/ckkboy/article/details/99584987

     

    问题5:

    1 /usr/bin/ld: 找不到 -lmsc
    2 collect2: error: ld returned 1 exit status

    解决:

    1 安装boost

     

    参考博客:
    https://blog.csdn.net/qq_32115101/article/details/89220824
    https://blog.csdn.net/ckkboy/article/details/99584987

    boost安装和卸载:

    1 $  sudo apt-get install libboost1.54-dev(安装)
    2 $ sudo apt-get autoremove libboost1.54-dev(卸载)

    运行 sudo ./b2 的结果:

     

     

    查看版本:

    1 dpkg -S /usr/include/boost/version.hpp

    boost 版本结果:

     

     

    问题6:

    1 /home/wei/moveit_wei2/src/ecto/samples/experimental/necto.cpp:247:56: error: ‘boost::asio::ip::tcp::acceptor {aka class boost::asio::basic_socket_acceptor<boost::asio::ip::tcp>}’ has no member named ‘get_io_service’
    2        connection_ptr new_conn(new connection(acceptor_.get_io_service()));

     

    解决:

    1 修改文件/ecto/samples/experimental/necto.cpp第247行和第265行。

    问题7:

    1 error: ‘class boost::asio::io_context::strand’ has no member named ‘get_io_service’

    解决:需要修改ecto/src/lib/strand.cpp,修改第95行的代码:

    1 boost::asio::io_service& serv_inside_strand = thestrand->get_io_service(); //改前
    2  boost::asio::io_context& serv_inside_strand = thestrand->context() ;  //改后

    参考博客:https://blog.csdn.net/u013013023/article/details/108715340

     

     

     

    一、生成配置文件

    cp 命令 :把一个文件拷贝到另一个目录。

    grep 命令:用于查找文件里符合条件的字符串。

    /是指根目录:就是所有目录最顶层的目录。

    ./表示当前目录,./ 一般需要和其他文件夹或者文件结合使用,指代当前目录下的东西。

    1 cd ..          切换到上级目录   
    2 cd ../文件夹    切换到上级目录中的某个文件夹

    参考链接:https://www.yisu.com/zixun/131889.html

    make 是编译。

    make install 是安装。

     

    在linux系统中,使用vi编辑,在命令行模式(按ESC)下 按 u 是撤销,相当于windows 下的ctrl+z。

    取消上一步操作是 ctrl+r 相当于window下的 ctrl+y,有了这两个快捷键操作起来就会方便很多。

    参考博客:https://blog.csdn.net/qq_31382921/article/details/77993860

     

    1.创建模型

    加载 urdf 模型:

     

    虚拟关节:创建机械臂和世界坐标系联系的部分,主要用于移动机械臂。

     

    2.机械臂规划组:有两个控制组

    第一个:六个关节

    第二个:前爪:前端不需要运动学插件。

    选择 KDL 运动学

     

    3.自定义点位

    初始点位:本教程设置名字为 home 。

    4.终端夹具配置

     

    5.消极关节

    不需要考虑和计算的关节,就是叫做 消极关节,不需要去做配置。

     

    6.作者信息

    package.xml包里设置好 各个功能包的姓名和联系方式,使用别人的功能包可以通过package.xml包向别人请教问题。

     

    7.生成配置文件

     

    把一系列的配置文件放在 marm_moveit_config 文件夹里面,之后可以直接 rosrun 这个文件夹即可。

    生成的文件有:

     

     

    二、功能测试

    1.阶段一的模型可以生成一个 demo.launch 文件,可以用这个文件检查配置流程是不是正确的。

    启动 demo.launch 文件:

    1 roslaunch marm_moveit_config demo.launch

     

    MotionPlanning 是 MoveIt 插件:

     

    问题:

    1 ==ROS-找不到launch文件。==

    解决办法:

    1 $   cd ~/catkin_ws/
    2 
    3 $   catkin_make
    4 $   source devel/setup.bash
    5 
    6 $   echo $ROS_PACKAGE_PATH   /home/ideallic/catkin_ws/src:/opt/ros/indigo/share:/opt/ros/indigo/stacks
    7 $   export | grep ROS

    原理解释:

    来到工作空间下对工作空间进行编译,并使用 source 命令配置环境变量。

    出现这个报错信息的原因是工程中新建一个 launch 文件后,没有及时配置环境变量,导致 roslaunch 命令无法识别到新添加的 launch 文件。

    参考博客:https://zhuanlan.zhihu.com/p/94971196

     

    2.加入场景物体

    下载Gazebo模型库:

    1 git clone https://github.com/osrf/gazebo_models

    下载挺慢的,要十几分钟。

    把 bowl.dae 加入到场景中。

     

     

    问题:

    .gazebo 文件夹没显示。

    解决:

    在页面 ctrl + h 即可出现 .gazebo 文件夹。

     

    三、完善模型

     

    对urtf 和launch 文件进行编写等,不断完善模型。

    启动仿真环境:

    1 roslaunch marm_gazebo arm_world.launch

     

    问题1:

    1 [Err] [REST.cc:205] Error in REST request

    解决:

    1 sudo gedit ~/.ignition/fuel/config.yaml
    2 
    3 然后将  url : https://api.ignitionfuel.org   用 # 注释掉
    4 添加   url: https://api.ignitionrobotics.org  

    问题2:

    1 [gazebo_gui-2] process has died [pid 72816, exit code 134, cmd /opt/ros/melo

    解决:

    1 echo $ROS_PACKAGE_PATH 
    2 
    3 export SVGA_VGPU10=0
    4 roslaunch marm_gazebo arm_world.launch

    要使更改永久使用:

    1 $ echo "export SVGA_VGPU10=0" >> ~/.bashrc

    参考博客:https://blog.csdn.net/xiaodingqq/article/details/86660902

    四、ros_control

     

     

     

     

     

    五、配置并加载控制器

     

    启动仿真环境:

    1 roslaunch marm_gazebo arm_gazebo_control.launch

    控制单轴运动:

    1 rostopic pub /marm/joint2_position_controller/command std_msgs/Float64 1.0

    RRBot栗子 可以学习到 Rviz 和 Gazebo 结合。

    参考博客:https://blog.csdn.net/weixin_43455581/article/details/10633422

     

    监控机器人状态::

    1 rostopic echo /marm/joint_states

    问题:

    1 WARNING: topic [/marm/joint_states] does not appear to be published yet

    没有输出正确的信息,而是出现了警告。

    六、MoveIt 和 Gazebo 集成

    1 roscore
    2 
    3 echo $ROS_PACKAGE_PATH
    4 
    5 roslaunch marm_gazebo arm_bringup_moveit.launch

     

     

    问题:

     

    若在rviz中出现**global status:warn**警告,

    则运行:

    1 rosrun tf static_transform_publisher 0 0 0 0 0 0 map base_link 50

    Rviz 添加模型,点击add添加robotmodel

    第一次运行时rviz并不会正常显示模型,需要设置一些配置

    1. 首先去到Display——Fixed Frame选则baselink

    2. 然后点击Add添加rviz——RobotModel

    3. 我这边设置的尺寸有点大,记得缩放视野,在rviz窗口的右边增加distance或者滑滚轮

    4. 再根据自己的喜好设置要显示什么信息

    如果不保存config,以后重新打开rviz都要重新设置一遍,因此可以点击file——save config as保存到launch文件夹里命名为config.rviz。再打开之前的launch file ,把第9行改成

    1 <node name="rviz" pkg="rviz" type="rviz" args="-d $(find RRrobot_description)/launch/config.rviz"/>

    这样以后都不用重新配置了。一下是rviz结果。

     

    参考博客:https://blog.csdn.net/mr_yu_1997/article/details/115429001

    https://www.pianshen.com/article/3870319148/

     

    七、如何使用MoveIt!控制机械臂运动?

    1、用户接口:

     

     

    2、编程接口:

     

     

     

    3、编程模式:

     

    4、关节空间运动:

    点到点运动:不需要在笛卡尔空间规划末端运动轨迹,机器人各个关节运动不需要联动。

    5、设置关节角度:

     

     

    雪儿言
  • 相关阅读:
    BZOJ4889: [TJOI2017]不勤劳的图书管理员
    BZOJ3932: [CQOI2015]任务查询系统
    BZOJ1926: [Sdoi2010]粟粟的书架
    POJ 3281 Dining(网络流-拆点)
    POJ 1273 Drainage Ditches(网络流-最大流)
    POJ 1325 Machine schedine (二分图-最小点覆盖数=最大匹配边数)
    HDU 1281 棋盘游戏
    HDU2255 奔小康赚小钱钱(二分图-最大带权匹配)
    HDU 2444 The Accomodation of Students (二分图存在的判定以及最大匹配数)
    POJ 3660 cow contest (Folyed 求传递闭包)
  • 原文地址:https://www.cnblogs.com/weixq351/p/14907783.html
Copyright © 2011-2022 走看看