当前位置:   article > 正文

Gazebo仿真UUV水下机器人_uuvsimulator

uuvsimulator

最近准备学习一下ros,gazebo和一个水下rov模拟器。

uuv_simulator(https://github.com/uuvsimulator/uuv_simulator)是一个非常优秀的基于ROS&GAZEBO开源水下机器人仿真项目,能为水下机器人的应用与算法提供一个较为理想的仿真环境进行测试。更详细的内容请仔细研读项目的wiki资料。

项目的机器人模型有两款ROV:desistek_saga与rexrov2,两款AUV:eca_a9与lauv_gazebo。项目内都提供了链接。同时在RexROV2的项目中《Development and Commissioning of a DP system for ROV SF 30k》一文详细介绍了如何构建水下机器人模型,值得了解一下。

在这里要说明的是仿真环境毕竟是虚拟的,水下使用光学相机不可能有这么好的能见度。实际上uuv_simulator里是有水雾设定以模拟水下光的衰减的情况,具体可以阅读其论文。不过此次仿真测试没有使用。

      最后简要说一下怎么安装和测试。

首先根据网上资料安装好ros noetic和gazebo,下面是针对uuv的导入:

   安装:

    mkdir -p xxx/src
    cd xxx/src
    git clone https://github.com/uuvsimulator/uuv_simulator.git
    git clone https://github.com/cabinx/cabin_auv_simulation.git
    cd ..
    catkin_make

注意:我个人的系统为ubutu20.04,ROS版本为neotic,Gazebo版本为11.0。所以编译uuv_simulator时出现了一些问题,具体如下:

一、gazebo11与sdformat-9.2问题

sdformat版本升级后,编译器的版本支持也需要做出相应改动。大致会出现如下报错:

/usr/include/sdformat-9.2/sdf/Param.hh:72:57: error: expected constructor, destructor, or type conversion before ‘;’ token template<class T> ParamStreamer(T) -> ParamStreamer<T>; /usr/include/sdformat-9.2/sdf/Param.hh:83:47: error: ‘variant’ is not a member of ‘std’ ParamStreamer<std::variant<Ts...>> sv)

根据error的log定位到uuv_gazebo_plugins的package,在其目录下的CMakeLists.txt中添加对c++17的支持:

  1. set(CMAKE_CXX_STANDARD 17)
  2. set(CMAKE_CXX_STANDARD_REQUIRED ON)

二、gazebo11与Ignition Math库问题

Ignition Math库相应升级到了v6版本,库内一些类的命名也有所变动,导致编译时出现错误。在此给出v4版本和v6版本的API链接:

V4:https://ignitionrobotics.org/api/math/4.0/namespaceignition_1_1math.html

V6:https://ignitionrobotics.org/api/math/6.7/namespaceignition_1_1math.html

还是在uuv_gazebo_plugins的package中,http://HydrodynamicModel.cc中计算bounding box调用的类发生了改动,原代码为ignition::math::Box ,新版本更名为 ignition::math::AxisAlignedBox,而新版本的ignition::math::Box是新的实现。需要在BuoyantObject.hh,http://BuoyantObject.cchttp://HydrodynamicModel.cc中做出相应修正。

1、对于BuoyantObject.hh:

  1. public: void SetBoundingBox(const ignition::math::Box &_bBox);
  2. ...
  3. protected: ignition::math::Box boundingBox;

修改为:

  1. public: void SetBoundingBox(const ignition::math::AxisAlignedBox &_bBox);
  2. ...
  3. protected: ignition::math::AxisAlignedBox boundingBox;

2、对于http://BuoyantObject.cc

  1. void BuoyantObject::SetBoundingBox(const ignition::math::Box &_bBox)
  2. {
  3. this->boundingBox = ignition::math::Box(_bBox);
  4. gzmsg << "New bounding box for " << this->link->GetName() << "::"
  5. << this->boundingBox << std::endl;
  6. }

修改为:

  1. void BuoyantObject::SetBoundingBox(const ignition::math::AxisAlignedBox &_bBox)
  2. {
  3. this->boundingBox = ignition::math::AxisAlignedBox(_bBox);
  4. gzmsg << "New bounding box for " << this->link->GetName() << "::"
  5. << this->boundingBox << std::endl;
  6. }

3、对于http://HydrodynamicModel.cc

  1. // FIXME(mam0box) This is a work around the problem of the invalid bounding
  2. // box returned by Gazebo
  3. if (_sdf->HasElement("box"))
  4. {
  5. sdf::ElementPtr sdfModel = _sdf->GetElement("box");
  6. if (sdfModel->HasElement("width") && sdfModel->HasElement("length") &&
  7. sdfModel->HasElement("height"))
  8. {
  9. double width = sdfModel->Get<double>("width");
  10. double length = sdfModel->Get<double>("length");
  11. double height = sdfModel->Get<double>("height");
  12. ignition::math::Box boundingBox = ignition::math::Box(
  13. ignition::math::Vector3d(-width / 2, -length / 2, -height / 2),
  14. ignition::math::Vector3d(width / 2, length / 2, height / 2));
  15. // Setting the the bounding box from the given dimensions
  16. this->SetBoundingBox(boundingBox);
  17. }
  18. }

修改为:

  1. // FIXME(mam0box) This is a work around the problem of the invalid bounding
  2. // box returned by Gazebo
  3. if (_sdf->HasElement("box"))
  4. {
  5. sdf::ElementPtr sdfModel = _sdf->GetElement("box");
  6. if (sdfModel->HasElement("width") && sdfModel->HasElement("length") &&
  7. sdfModel->HasElement("height"))
  8. {
  9. double width = sdfModel->Get<double>("width");
  10. double length = sdfModel->Get<double>("length");
  11. double height = sdfModel->Get<double>("height");
  12. ignition::math::AxisAlignedBox boundingBox = ignition::math::AxisAlignedBox(
  13. ignition::math::Vector3d(-width / 2, -length / 2, -height / 2),
  14. ignition::math::Vector3d(width / 2, length / 2, height / 2));
  15. // Setting the the bounding box from the given dimensions
  16. this->SetBoundingBox(boundingBox);
  17. }
  18. }

三 .错误:

[ 97%] Linking CXX shared library /home/wmc/space/gazebo/uuv/devel/lib/libuuv_gazebo_ros_base_sensor_plugin.so
/home/wmc/space/gazebo/uuv/src/uuv_simulator/uuv_sensor_plugins/uuv_sensor_ros_plugins/src/gazebo_ros_image_sonar.cpp: In member function ‘cv::Mat gazebo::GazeboRosImageSonar::ConstructVisualScanImage(cv::Mat&)’:
/home/wmc/space/gazebo/uuv/src/uuv_simulator/uuv_sensor_plugins/uuv_sensor_ros_plugins/src/gazebo_ros_image_sonar.cpp:945:71: error: ‘CV_AA’ was not declared in this scope; did you mean ‘CV_AVX’?
  945 |   cv::ellipse(scan, center, axes, -90, -fov/2.-0.5, fov/2., white, 1, CV_AA); //, int lineType=LINE_8, 0);
      |                                                                       ^~~~~
      |                                                                       CV_AVX

定位gazebo_ros_image_sonar.cpp,加入头文件

#include <opencv2/imgproc/imgproc_c.h>

至此,编译顺利通过,仿真运行也没有问题。

(以上是引用的其他博主的文章和一些自己的问题,在此表示感谢!)

————————————————
版权声明:本文为CSDN博主「cabinx」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/xiekaikaibing/article/details/114984613
 

启动湖泊

roslaunch uuv_gazebo_worlds auv_underwater_world.launch

启动环境和水下机器人pid控制

执行命令:

roslaunch uuv_gazebo start_pid_demo_with_teleop.launch

(未完待续)

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/378990
推荐阅读
相关标签
  

闽ICP备14008679号