Ubuntu20 uuv_simulator 安装

2 篇文章 1 订阅
1 篇文章 0 订阅

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,首先下载源码(网上挺多教程的)

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)

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

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

修改为:

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

(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;
}

改成:

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;
}

(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);
    }
  }

改成:

// 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);
    }
  }

(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

  • 4
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值