基于ROS搭建仿真环境——B站苏的一休抓取环境复现

大佬链接:https://www.bilibili.com/video/BV19f4y1h73E?vd_source=6f2fc443cc3323efe0300c7cb662e8a8

搭建

此功能包在Ubuntu16.04上经过测试,应该适用于其他Linux版本。在你的Catkin工作空间中需要有

  • 负责计算aruco二维码位姿态的aruco_ros
  • 使用点云的基于深度学习的抓取位姿检测gpd_ros(这个包还需要编译安装GPD library);
  • 手眼标定功能包easy_handeye
  • UR机械臂的ROS功能包universal_robot
  • 此外在robot_sim/package中有一些需要用到的但我在上面进行过一些修改的包,如解决gazebo中抓取物体会莫名抖动的包gazebo-pkgs,大寰机器人二指抓手AG-95的ROS功能包dh_gripper_ros以及其他依赖等。

安装easy_handeye及其依赖

按照官方步骤:

  • clone this repository into your catkin workspace:
cd ~/catkin_ws/src  # replace with path to your workspace
git clone https://github.com/IFL-CAMP/easy_handeye
git clone -b melodic-devel https://github.com/pal-robotics/aruco_ros
  • 安装依赖 (aruco_ros,visp_hand2eye_calibration)
cd ..  # now we are inside ~/catkin_ws
rosdep install -iyr --from-paths src

若安装不成功,可手动安装。或去github下载功能包源码至~/catkin_ws/src,catkin_make编译即可。

sudo -H apt-get install -y ros-melodic-visp-hand2eye-calibration
sudo -H apt-get install -y ros-melodic-aruco-ros
  • build
catkin_make

至此,这里已经自动安装好了aruco_ros!

下载vision_opencv

https://github.com/ros-perception/vision_opencv

再是aruco_ros安装:

https://blog.csdn.net/qq_33328642/article/details/122267004

ERROR:

/usr/include/python2.7/numpy/__multiarray_api.h:1537:144: error: return-statement with no value, in function returning ‘void*’ [-fpermissive]

cv_bridge python 版本编译问题!

解决方案:

https://blog.csdn.net/qq_44876051/article/details/112370423

安装GPD 及GPD_ROS

Clone the repository into some folder:

git clone https://github.com/atenpas/gpd

Build the package:

cd gpd
mkdir build && cd build
cmake ..
make -j

You can optionally install GPD with sudo make install so that it can be used by other projects as a shared library.

If building the package does not work, try to modify the compiler flags, CMAKE_CXX_FLAGS, in the file CMakeLists.txt.

检测:./detect_grasps ../cfg/eigen_params.cfg ../tutorials/krylon.pcd

这里出现段错误问题可以把CMakeList文件下的find pcl 1.9改为 find pcl! 还有set部分!

在这里插入图片描述

gpd_ros:

cd <location_of_your_workspace>/src
git clone https://github.com/atenpas/gpd_ros`
#Build your catkin workspace:
cd <location_of_your_workspace>
catkin_make`

ERROR: 编译期间pcl冲突

https://blog.csdn.net/m0_53621852/article/details/121915687

解决方案

sudo apt-get install ros-melodic-pcl-conversions

后续环境出现问题更换后选择gpd-forword(类似gpd1.5)和gpg同时编译,过程略过
https://blog.csdn.net/flyfish1986/article/details/85791714?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_title~default-5-85791714-blog-122412170.pc_relevant_downloadblacklistv1&spm=1001.2101.3001.4242.4&utm_relevant_index=8
更改gpd-forword里的CMakelist文件,记得重命名为gpd

问题没解决,莫名其妙又编译通过了

其他功能包:

#git clone -b melodic-devel https://github.com/pal-robotics/aruco_ros

git clone -b kinetic-devel https://github.com/ros-industrial/universal_robot.git    #universal_robot

git clone https://github.com/Suyixiu/robot_sim                                      #本功能包
cd ..
#rosdep install --from-paths src --ignore-src --rosdistro=kinetic                    #安装依赖
rosdep install --from-paths src --ignore-src --rosdistro=melodic  

catkin_make
cp -r ./src/robot_sim/experiment/hand_eye_calibration/urdf/aruco/ ~/.gazebo/models  #复制aruco模型到gazebo默认模型文件夹中

ERROR:

CMake Error at robot_sim/experiment/CMakeLists.txt:61 (find_package): Could not find a configuration file for package “OpenCV” that is compatible with requested version “3.3.1”.

将CMakeList文件中这一行的代码改为

#set(OpenCV_DIR /opt/ros/kinetic/share/OpenCV-3.3.1-dev)
#find_package( OpenCV 3.3.1 REQUIRED )
find_package(OpenCV REQUIRED)

ERROR:
在这里插入图片描述

解决方案:

https://github.com/Suyixiu/robot_sim/issues/2

moveit melodic版本问题

将11行内容改为

#include <moveit/move_group_interface/move_group_interface.h>

29行改为

moveit::planning_interface::MoveGroupInterface group(“manipulator”);

ERROR:

在这里插入图片描述

tf代码声明问题:

reset_robot_pose.cpp添加头文件

#include <tf/transform_broadcaster.h>

ERROR:

  • /home/xty/robot_sim_ws/src/robot_sim/package/dh_robotics_gripper/dh_robotics_ag95_gripper/dh_robotics_ag95_simulation/roboticsgroup_gazebo_plugins/src/mimic_joint_plugin.cpp:38:18: error: ‘DisconnectWorldUpdateBegin’ is not a member of ‘gazebo::event::Events’
    event::Events::DisconnectWorldUpdateBegin(this->updateConnection);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~

gazebo 版本问题(本人用9 代码为7)

https://blog.csdn.net/Mike_69/article/details/117479477

https://blog.csdn.net/weixin_44584250/article/details/108569842

event::Events::DisconnectWorldUpdateBegin(this->updateConnection);
to
this->updateConnection.reset();
GetPhysicsEngine()->
to
Physics()
GetAngle(0).Radian();
to
Position ( 0 )
gazebo::math::clamp
to
ignition::math::clamp

ERROR:

  • error: ‘cvMoveWindow’ was not declared in this scope

把代码中的cv去掉!改为cv::moveWindow()

将xacuo文件移植

cp -r ./src/robot_sim/experiment/hand_eye_calibration/urdf/aruco/ ~/.gazebo/models

编译结束!!!!!!!撒花!!! 😆

相机标定

cd ~/your_catkin_ws/
roslaunch robot_sim camera_calibration.launch

cameracalibrator.py脚本为例。你可以选择你所需要标定的相机。

(暂时不用)

rosrun camera_calibration cameracalibrator.py --size 7x6 --square 0.01 image:=/camera/rgb/image_raw camera:=/camera/rgb     #RGB相机
rosrun camera_calibration cameracalibrator.py --size 7x6 --square 0.01 image:=/camera/ir/image_raw camera:=/camera/ir       #IR相机

接下来是移动标定板,程序中设定的是1秒钟产生一个随机位置并移动标定板,若相机能正确识别出标定板角点则将此时的照片保存,有深度图,红外相机的图还有RGB图存放在save_checkboard_img目录中。当你觉得采的图片足够多之后即可停止这个程序。

cd ~/your_catkin_ws/
rosrun robot_sim camera_calibration

这里我们提供了一个python的脚本camera_calibration.py,位于robot_sim/experiment/camera_calibration/scripts,用于载入前面保存的图片以计算RGB相机与IR相机的内参并分别保存在IR_cameraintrinsic_parameters.npzRGB_cameraintrinsic_parameters.npz中,直接python运行此脚本即可。你也可以自己写程序来计算内参,并与前面公式计算的结果像对比以验证你的标定算法的准确性与误差。

cd ~/your_catkin_ws/src/robot_sim/experiment/camera_calibration/scripts
python3 camera_calibration.py`

注意!! 代码中需要将#sys.path.append(“/opt/ros/kinetic/lib/python2.7/dist-packages”)注释掉

标定文件保存在

/home/xty/robot_sim_ws/src/robot_sim/experiment/camera_calibration/scripts/RGB_cameraintrinsic_parameters.npz

在仿真环境中进行深度图配准

此实验将用到实验一中采集的两个相机拍摄的标定板的图片,这里我们提供了一个python脚本depth_image_registration.py来计算配准矩阵并将其前两行存放在Registration_matrix.txt中,因为实际remap深度图的时候也只会用到前两行。

cd ~/your_catkin_ws/src/robot_sim/experiment/depth_image_registration/scripts
python3 depth_image_registration.py

随后可以随便拿一对RGB图与深度图来观察配准矩阵对不对,因为后面会用到这个矩阵所以这里直接就是写成CPP了。

cd ../src
g++ ./depth_image_registration.cpp -o depth_image_registration $(pkg-config --cflags --libs opencv)
./depth_image_registration

在这里插入图片描述

在仿真环境中进行手眼标定

这里使用的手眼系统属于眼在手上的情况,即eye on hand,首先将我们提供的机械臂的moveit功能包跑起来,其中加载了UR10机械臂、大寰机器人的AG-95二指抓手还有D435i RGBD相机安装在UR10机械臂的末端。这里的手的link是yixiuge_ee_link,眼的link是相机的RGB光学framecamera_rgb_optical_frame。标定用到的Aruco二维码的大小是0.2m,ID是582。

roslaunch yixiuge_ur10_moveit_config yixiuge_ur_moveit.launch

ERROR:

ps: 注意可能会有文件不存在的报错 记得移到.gazebo文件夹下!!

ps: control + h 在主目录查看!

在这里插入图片描述

ERROR:

在这里插入图片描述

报错解决:

https://blog.csdn.net/weixin_46658421/article/details/116451344

sudo apt-get install ros-melodic-trac-ik-kinematics-plugin
sudo apt-get install ros-melodic-moveit-*
sudo apt-get install ros-melodic-trac-ik
#重新编译!

需要等moveit加载完之后再加载手眼标定包,因为大寰的二指抓手开起来有点费时,如果马上开hand_eye_calibration的话可能因为找不到moveit的group而报错。

roslaunch robot_sim hand_eye_calibration.launch

ERROR:
在这里插入图片描述

报错解决:文件未找到

https://blog.csdn.net/weixin_46658421/article/details/117033344

http://t.zoukankan.com/long5683-p-13847352.html(xml)

cd Downloads
git clone https://github.com/aquahika/rqt_virtual_joystick.git
sudo cp -r ~/Downloads/rqt_virtual_joystick/resource /opt/ros/melodic/share/rqt_virtual_joy/
rm -rf ~/Downloads/rqt_virtual_joystick

ERROR:

sudo: error in /etc/sudo.conf, line 0 while loading plugin ‘sudoers_policy’
sudo: /usr/lib/sudo/sudoers.so must only be writable by owner
sudo: fatal error, unable to load plugins

修改文件权限即可:

https://blog.csdn.net/lileihappy/article/details/79214156

sudo chmod 644 /usr/lib/sudo/sudoers.so
sudo chown -R root /usr/lib/sudo

ERROR:
在这里插入图片描述

报错解决:

原因是没有source。所以解决方案就是在编译完成之后添加source devel/setup.bash,问题解决。

ERROR:

error while loading shared libraries: libvisp_vision.so.3.5: cannot open shared object file: No such file or directory

报错解决:

sudo apt-get install libvisp-dev
sudo apt-get install ros-melodic-visp
sudo apt-get install ros-melodic-vision-visp

https://blog.csdn.net/qq_41535193/article/details/124237390#t9

ERROR: 点击Take Sample 闪退

Error processing request: “camera_marker” passed to lookupTransform argument source_frame does not exist.

报错解决:https://blog.csdn.net/gyxx1998/article/details/122238052#t16

打开rqt_image_view 显示对准二维码,然后让rviz中出现了这个坐标

注意realsense需要单独启动
在这里插入图片描述

ERROR: 点击Take Sample 闪退

点击check pose 报错

‘tuple‘ object has no attribute ‘joint_trajectory‘

https://blog.csdn.net/LWLGZY/article/details/121106934

修改代码

/home/xty/robot_sim_ws/src/easy_handeye/rqt_easy_handeye/src/rqt_easy_handeye/rqt_calibrationmovements.py 96行 108行

#plan = self.mgc.plan()
plan_success, plan, planning_time, error_code = self.mgc.plan()

ERROR: 点击next pose plan 闪退

挖坑! 这里用的是ag95抓手,以后有需要的话要手动替换其他抓手

在这里插入图片描述
结束!
在这里插入图片描述

基于几何学习的抓取实验

roslaunch robot_sim grasp_world.launch 
cd ~/your_catkin_ws/                                #这是必要的
rosrun robot_sim geometric_method_grasp             #因为这里要加载mask所以路径要对

wooden_peg ERROR

记得修改代码,然后catkin_make 生效!

在这里插入图片描述
在这里插入图片描述

点击两下第一个按钮自动执行,成功!

基于机器学习的抓取实验

ERROR:wooden_peg

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-UmGucevJ-1655376229503)(https://s3-us-west-2.amazonaws.com/secure.notion-static.com/032e7e77-141d-479a-bf94-8f1a5bc64048/2022-06-15_00-57-56屏幕截图.png)]

同理,gpd_method里的main方法注释掉这部分,还要修改下面的循环遍历i < 4!

ERROR:

roslaunch robot_sim gpd_run.launch type:=2 topic:=/cloud_sample

作者写错了路径,在gpd_run.launch文件下,把config_file 的value改成对应gpd文件下的ros_eigen_params.cfg 里面的参数可以按照 eigen_param.cfg进行修改,因为detect_grasp就是用的这个!

使用过程要在那个窗口按q,直到出现selected grasps结果,再按q。

直到rosrun robot_sim GPD_method_grasp这个窗口出现receive grasp,就可以按照视频过程点击两下good grasp实现抓取!!!!!!!!

撒花!

在这里插入图片描述

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
乘风的头像乘风管理团队
上一篇 2023年2月26日 下午1:08
下一篇 2023年2月26日 下午1:09

相关推荐