当前位置:   article > 正文

Ubuntu20 uuv_simulator 安装_uuvsimulater 教程

uuvsimulater 教程

Ubuntu20 uuv_simulator 安装编译

如果你是Ubuntu16 ,17,18 直接下面一行代码就搞定(装在系统目录那里)
kinetic版本:sudo apt install ros-kinetic-uuv-simulator
lunar版本:sudo apt install ros-lunar-uuv-simulator
melodic版本:sudo apt install ros-melodic-uuv-simulator

但是Ubuntu20 不能直接用命令行完成傻瓜式安装,接下来给出一个我认为比较方便的方式,可以让你们编译通过。

发现github上有了noetic版本的了,可以完美编译通过:

https://github.com/arturmiller/uuv_simulator/tree/noetic

或者直接通过命令行下载

git clone --branch noetic https://github.com/arturmiller/uuv_simulator.git
  • 1

理论上是没有问题的,本人在本机上已经验证实现,如有问题可以在评论区留言。

以下的内容不用看了,是过去发布的,懒得删,就当作记录吧,是比较麻烦的操作。

1,首先下载源码(网上挺多教程的)

https://uuvsimulator.github.io/installation/

2,编译

这时候你会发现编译是不能通过的,因为源码用的是opencv是旧版 ,而ubuntu20用的是opencv4,而且ros2用的是gazebo11,所以需要修改一些文件。

(1)打开uuv_gazebo_plugins功能包,在其目录了下添加CMakeLists.txt中添加对c++17的支持:

在文件头find_package()之前添加:

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

(2)在BuoyantObject.hh文件中:(这个在uuv包里直接搜索就行)
把BOX 改成AxisAlignedBox

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

修改为:

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

(3)BuoyantObject.cc文件,把BOX 改成AxisAlignedBox:

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

改成:

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

(4)HydrodynamicModel.cc文件:

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

改成:

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

(5)gazebo_ros_image_sonar.cpp 中:
把CV_AA全部改成cv::LINE_AA

编译通过。

参考:
https://blog.csdn.net/xiekaikaibing/article/details/111041718
https://stackoverflow.com/questions/19545487/opencv-enum-variableslike-cv-bgr2gray-or-cv-aa-missing-in-the-recent-java-api

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

闽ICP备14008679号